Hi Everyone,
My task is to read some data in .txt file, like this as example.
"11 03 AC 78 cplusplus is the best 4595890 5677...
83 G 450 A My topics 2344879 139..
WQ 3 11 124 UNIX/Linux Programming 234235 1341..."
Each line starts with 4 string field, maybe number or string, then follow the multiple words i would like to store in one single string field, after that the numerical code and fields.
With the known numbers of words i can use fscanf() to read each field by field, but variable multiple words, like "cplusplus is the best", "My topics", "UNIX/Linux Programming" shown above. How can i capture those and store in a single string field?
Yes, we can; but should we? For the beginner, the library provides easy to use facades like std::ifstream - far easier than, say, understanding the intricacies of std::scanf().
If we must do this with the standard C subset of the input/output library,
something like this, perhaps (caveat: not even cursorily tested):