Hi,
I am getting a segmentation fault at the following line in the code. I am reading a file using ifstream. The file contains some initial junk data followed by useful data. I wish to read and discard the junk data from the file, before I read the useful data. When i read the following string "cls" i know that i have read all the junk data and now i will read the useful data.
I am using "compare" operator to compare the value read from the file and "cls". I am getting a segmentation fault at line number 4. Following is my code:
string junk;
string junk1 = "cls";
inFile >> junk;
while(!(junk.compare(junk1)))
{
inFile >> junk;
}
I am unable to figure the cause. any help is appreciated.
Thanks