hello
i want to read from a file, i know how to read line by line or word by word ,,, iwant combination of them,,
for example,, if i have file named "data",, that contian
1 2 3 4
|
2 2 m3 m5
4 8 2 m1
8 1 m7
|
to read the file i write this code
1 2 3 4 5 6 7 8 9 10
|
ifstream fin("data.txt");
string s;
//if i want to read word by word
while (fin>>s)
cout<<s<<endl;
// if i want to read line by line
while (getline(fin,s))
cout<<s<<endl;
|
what about if i want to read each word in each line,, so i can manipulate each line separetly ,, attention that the number of words differ from line to line,,,
i mean i want to read the first line which is
2 2 m3 m5,, then manipulate each word in this line separeatly,, after finishing i can read the second line with its words,,,
i hope my question is clear :)