Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read file data into multidimensional array

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello all!!

I have an input file which is in this form.

00121
01145
...
59166

the first two integers of each line represents the row and column of a multidimensional array. the next three are values to be assigned to a structure . i.e each cell of array has a structure in it.there can be repeating lines. i am trying to write a function which reads this file and stores these values in a multidimensional array.
can anybody help me with this? my compiler won't recognize .getline()

thanks
 
For things like this, I build a console app taht does not use mfc. i include <fstream.h> <string.h> and any other things you may find necessary

With the knowledge that no number will have more then one digit in it, i would use ifstream

ifstream inFile(&quot;input.txt&quot;);

// i am pretty sure there is an &quot;isdigit&quot; funciton
// do a search on it

now i would use

inFile.get(); to get a character at a time and go from there

Good luck

matt
 
the getline is:
char buffer[size_of_buffer]
file.getline(buffer,size_of_buffer);
of
file.getline(buffer,size_of_buffer,'x');
//the last parameter represents the value untill to read
//the line.
Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top