Hey guys. Ive been working with fstream for about 2 hours and i give up. My problem is I have a text file with an unknown number of rows. Each row has a known number of items. i cant figure out how to read the elements in each row. after that i know i can finish what i have to do but its just the row by row thats killin me. Any help would be appreciated. Thanks
Barefootsanders
0
Junior Poster
Recommended Answers
Jump to Postpost one of the rows so we can see what kind of items it has. Generally, if they are all strings (or words). Assuming the name of the stream is in
std::string word; while( in >> word ) { // blabla }
Jump to Postsince you know there are 4 numbers on a row
int a,b,c,d; while( in >> a >> b >>c >>d ) { // blabla }
All 6 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Barefootsanders
0
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Barefootsanders
0
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Barefootsanders
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.