PDA

View Full Version : C: arrays and file help


sir pannels
05-01-2003, 03:36 PM
Hey,
ok ive never been good with arrays, in any of the code i use php perl and now, C...
Idealy i want to sort each line of a txt file into an array,so it can be called, like $line1 $line2 and so forth, but im getting no where, couldnt figure who to put the whole txt file into one array either im that bad lol
any help would be great :)
Thanks
Sir P:thumbsup:

eagle12
05-06-2003, 05:02 AM
use the fin.getline(str)

not sure of the exact syntax, but that is how you read in from a file, use a while(!fin.eof()) and it will read one line into each element. It keeps reading until it hits the "\n".