file io troble
i am creating a computergame atm.
a MMORPG for 50 players a time.
but i want to read a part of the map out of a file.
i am using the file iostream for this.
but is there a way to read it line for line??
and if i only need line 50 that he will leave the rest and only read line 50??
Well the short answer is to use a loop to count through the lines until you get the one you want.
A longer answer is to read every line of the file, and build up an index of 'tell' positions for each line, then you can 'seek' to any given line at a later time.
Unless the file is excessively large, then reading the whole file into memory (say a std::vector<std::string> of lines) is an alternative.