Hi Guys!

how to get the text from file before any space come

suppose i have file and it reads


Code:
aa    this is a
bb    this is b
cc    this is c

i am only interested in aa, bb, cc not the rest of the text. or in other words ignore the text that is after space.

so i came up with this code

Code:
std::ifstream file("abc.txt");
std::string str;
while (file >> str /* read next word */)
{
	std::cout << str << std::endl;
	file.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); /* ignore rest of line */
}

but there is problem, Is there any such a method in which I can use before or after this file.ignore(), to actually keep the rest of the line? I mean, the rest of the line shall be used.

Considering that the first column of the text file is an integer, something inside of the while loop like:


Code:
value = atoi(str.c_str());
(if value==1){
    cout <<restOfTheLine<<endl;
}
BR

Ewa