Avoiding Strings

Hello.

Is there a way to avoid different strings while using fopen?

Example:

Input (the file):
Say Hello!
Hello
Name please.
John


The code:
1
2
3
4
5
6
7
inFile.open(aFile);
Avoid("2 string"); // Help.
inFile >> GetAString;
Avoid("next 2 strings"); // Help.
inFile >> GetAnotherString;
inFile.close();
cout << GetAString << ", my name is " << GetAnotherString << "." << endl;


Output (console screen):
Hello, my name is John.


I hope you understand what I mean.
Any help appreciated.
Last edited on
why, yes of course. You just read them into any of your strings and ignore what they are.

1
2
inFile >> GetAString >> GetAString; //Read 2 strings
inFile >> GetAString; //read another string, and ignore the values of the previous ones 


Other than that, you would have to operate with the unformatted data, and do the logic yourself. See here: http://www.cplusplus.com/reference/iostream/ifstream/
Haha. Thanks!
Topic archived. No new replies allowed.