read file into a array

I have file that has number and words and all ends with a -1
how would i go about putting it into an array
for example;

so in the file.dat i have something like

6 5 yo moma 5 6 -1
9 sup chicken 2 5 -1
..etc

and i want to put the first line into one array and the seconds line into another arrays and so on
so something like this

array_1[] would have 6 5 yo moma 5 6 in it
array_2[] would have 9 sup chicken 2 5 in it
and so on



i am also using c++
Last edited on
There is no something like in programming. What is the exact format of the file? The rules about what is in it. Count and types of data items?


The std::string is "an array" (of char), so std::getline(istream&,string&) formally "puts into array".

All items of an array have to have the same type. If you want to have both numbers and words, then one array of type T objects is not what you need.
Topic archived. No new replies allowed.