Hi, I've just started with c++ and I have no clue how to do this. Right now I have a code that just printing out the text lines in my file and how many lines there is just to check that i can read from my file...
But what I want to do and can't figure out is to pick out and store numbers from text lines.
Consider this as user inputs to a file:
Number 10 Downing Street
My birthday is 6 May 1980
And now I want to read from the .txt file and store the number 10 from the first text line and then store 6 and 1980 from the second line of text.
//..Some codes to put in lines of user specific text to a file. [done]
//And now the code that outputs the text rows and number of rows in
//the file but have nothing to do with what i want to achive :(
ifstream inputfile(filename);
char text;
int n = 0;
while (inputfile.get(text))
{
cout.put(text);
if (text == '\n')
++n;
}
cout << endl << There is " << n << " rows of text";