Computing.Net > Forums > Programming > printing address of the integer

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

printing address of the integer

Reply to Message Icon

Name: sarahq
Date: June 16, 2006 at 21:08:13 Pacific
OS: winxp
CPU/Ram: 513
Product: dell
Comment:

i am trying to read a file and putting it into an arry. For some reason, when i am trying to print by array its not printing the integer but bunch of wried numbers. I know its printing the address of the integer but not the integer, but i do not remember how to fix it here is my code
FileInputStream inData;
DataInputStream read;
int store[] = new int[5];

try
{
BufferedInputStream (new FileInputStream ("inData.txt"));
inData = new FileInputStream("inData.txt");
read = new DataInputStream(inData);

for(int i=0; i < 5;i++){
store[i] = read.readInt();
}

}catch (Exception error)
{
System.err.println ("Error reading file");
}

for(int i = 0; i < 5; i++){
System.out.print(store[i]);}



Sponsored Link
Ads by Google

Response Number 1
Name: tanveer_don
Date: June 17, 2006 at 21:29:19 Pacific
Reply:

try to use this code this is working


public static void main(String args[])
{
//FileInputStream inData;
DataInputStream read;
int store[] = new int[5];

try
{
BufferedInputStream inData= new BufferedInputStream(new FileInputStream ("inData.txt"));
//inData = new FileInputStream("inData.txt");
read = new DataInputStream(inData);
for(int i=0; i < 5;i++){
store[i] = read.readInt();
}

}catch (Exception error)
{
System.err.println ("Error reading file");
}

for(int i = 0; i < 5; i++){
System.out.print(store[i]);}
}


0

Response Number 2
Name: sarahq
Date: June 22, 2006 at 06:27:01 Pacific
Reply:

5 2 1 4 3
2 5 3 4 1
1 4 2 3 5
2 3 5 4 1
4 5 2 1 3

above is couple lines from my file inData an here is what its reading :(


891302432824194080857743373171057205540221492


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: printing address of the integer

Address of array pointer. www.computing.net/answers/programming/address-of-array-pointer/975.html

internal structudre of Array in C++ www.computing.net/answers/programming/internal-structudre-of-array-in-c/939.html

get red of the last comma in C www.computing.net/answers/programming/get-red-of-the-last-comma-in-c-/9483.html