i am new to c++, currently working on an assignment, now i'm stuck in skipping the comment lines in the txt file.
the txt file is something like this:
#com1
A1
A2
A3
#com2
B1
B2
B3
...
what i need to do is to enter commands to display the text file contents. like when i enter cmd1, it shows A1-A3, enter cmd2 it shows B1-B3. but i don't know how to find the strings and skip those lines. the code i've got is
cout << "Please enter command: ";
cin >> command;
if(command == "cmd1") {
inFile.open("data.txt");
inFile >> product; //product repesents A1-A3..
while (inFile.good())
{
??????????????
??????????????
cout << product << endl;
inFile >> product;
}
}
the question marks is where i'm stuck, i tried cin.ignore() but it doesn't seem to work, i want to code something that can search the txt, find the exact string "#com1", and skip this line, help please... thanks in advance!