-
C++ File I/O Help
Ok so im working on a project... here are the specs:
I'm given a data.txt file with the following info:
0 || person_name || status
the 0 represents a number between 0-228 (not all the numbers in between)... basically this number is an "Arrival time" (this program is a simulation)..
The status field is tells what kind of person they are (specificly alumni , etc)
Basically my question is this... how do I read in data from a outside source? I want to store the numbers into an array, the name into a seperate array, and finally the status in another. (3 arrays)... How do I do that?
The specific assignment im trying to work on is located here:
http://www.cs.unt.edu/~roden/courses/3400/homework2.txt
and the data file is here:
http://www.cs.unt.edu/~roden/courses/3400/hm2_data.txt
thank you for your time.
-
Lots of views, yet no posts... Is there no one out there that can help?
-
First off it don't bump your posts. Someone will give you an answer when they have a chance.
Second you need to read this http://cboard.cprogramming.com/annou...ouncementid=39
-
>Lots of views, yet no posts... Is there no one out there that can help?
As one of the views, I feel obliged to defend my choice not to reply. You're problem is both uninteresting and common. That combination is good for being ignored as you can find your answer with a board search. I'm also sure plenty of people will reply to inform you of that. :D
-
im not asking you to do my homework for me... my question is simple (yeah sorry if its not interesting but oh well):
How do you input data from a text file into an array? ....
-
char *buf = new char[MAX_LEN];
ifstream data.open("test".txt);
data.getline(buf);
data.close()
delete buf;
That is very basic, and some of the syntax might be a bit off. But it will give you something to read into.
-
>im not asking you to do my homework for me...
I didn't think you were.
>yeah sorry if its not interesting but oh well
That wasn't my point. My point was that if you searched the boards before starting a new thread, you would have found your answer.