You may use getline() . Here's tutorial on file i/o. Read and try yourself, if you encounter any problem you can post here.
vishesh
Nearly a Posting Virtuoso
1,381 posts since Oct 2006
Reputation Points: 85
Solved Threads: 42
you mean you want to concantinate all those words into one big comma-separated string? Not too difficult to do if you use std::string c++ class
std::string the line;
while read a word is successful
line += string;
line += ", ";
end of while loop
now the line will have a trailing ", " which you will have to strip back off.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
you mean you want to concantinate all those words into one big comma-separated string? Not too difficult to do if you use std::string c++ class
std::string the line;
while read a word is successful
line += string;
line += ", ";
end of while loop
now the line will have a trailing ", " which you will have to strip back off.
Incorrect, the commas in his example were used merely to communicate the fact that the words are separate entities in the array.
It also appears that:
test1 ... test[n]
Has a defined pattern. In other words, it might be useful to consider using a class or struct to relate the items in some manner.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
>i have looked all though my textbook and all over the
>net and have not found any examples similar.
You mean you haven't found any examples that do exactly what you want. I find it hard to believe that there are no examples that are similar, because I've written a large number of examples that do this myself. Let's start with this: Do you know how to open and read from a file?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401