|
-
Dec 10th, 2003, 08:43 PM
#1
Thread Starter
Hyperactive Member
Any suggestions on how I should read in this file?.:Resolved:.
Hello everyone, I have a file set up like this:
100 93
43 30
80 70
... ...
these grades are seperated by a tab character, the first column is lab 1, the second column is lab 2, I want to seperate these 2 columns and manipulate them seperately, like, I will have to find the average of them, the mode of them, and the min and max of each lab, any idea's? I was trying to seperate them into 2 different arrays, but thats not working too well!
Code:
int array1[500];
int array2[500];
int one;
int two;
char ch;
char newline;
int i =0;
while(!inFile.eof())
{
inFile >>one>>ch>>two>>newline;
array1[i] = one;
array2[i] = two;
i++;
}
thanks!
Last edited by voidflux; Dec 11th, 2003 at 12:41 AM.
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
-
Dec 10th, 2003, 11:10 PM
#2
Try this: when you try to read an integer, it will skip whitespaces and newline to get to the next one. You made it too hard :P
Code:
int array1[500];
int array2[500];
int one;
int two;
int i =0;
while(!inFile.eof())
{
inFile >> one >>two;
array1[i] = one;
array2[i] = two;
i++;
}
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Dec 10th, 2003, 11:35 PM
#3
Thread Starter
Hyperactive Member
wow! thank u so much! i've spent about 4 hours on this! dear god! i'm going to snap hah thanks again!
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
-
Dec 13th, 2003, 09:59 AM
#4
Why even the temps?
Code:
int array1[500];
int array2[500];
int i =0;
while(!inFile.eof())
{
inFile >> array1[i] >> array2[i];
++i;
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 13th, 2003, 09:49 PM
#5
Thread Starter
Hyperactive Member
they really weren't needed, at the time it just came to me to use temps for some reason, when this problem comes up on the final i'll discard of them! thanks!
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|