Hi!
Im new to C++, but i already know everythingfrom tutorial on this site.
I have created a program to read a text file, and print it as one line
now, when i know the content of that line, i can store it as a string, or char
so, if i have a string that say's: "biggest_number 5"
how can i split that string to to integer with name biggest_number, and with value of 5
("biggest_number 5" would be one line in text file, other would be maybe "some_string 123", but that all is basically in same format)
now, this is the code that i wrote so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
{
char str[80];
ifstream opnfl;
opnfl.open("file.txt");
opnfl >> str;
/* if (data=="max_num"){
cout << "pos";
}
else {
}
//this is just for testing something, ignore
*/
//this is where i retrieve the first line
cout << str << endl;
opnfl >> str; //retrieve the second line
cout << str << endl;
opnfl.close();
|
so basically, i want to split text from the line into new char with name that is in the line, and with value that is in same line (name is followed by the value)
Thanks in advance!