I wonder something about this code that read(ifstream) a .txt file.
In my file I have these 2 lines:
Hello,1000,Yes,walker
How,2000,No,walker
So with my code I use getline with a delimiter to put these 4 different strings/int to variables.
The code works fine for the 2 first, wich is "Hello" and "1000".
The problem occurs when I am extracting "Yes" wich is a std::string.
I have used a MessageBox below to display what happens.
What happens is that when extracting "Yes" to std::string two. I get this output:
"Yes,walker"
Why does this happening though I use ',' as delimiter ? It seems that this is happening when a std::string occurs on the line.
What is possible to do to extract this line correctly (string, int, string, string)
ifstream File("C:\\Read.txt");
std::string one;
int Number = 0;
std::string two;
std::string three;
char Comma;
while( getline(File, one, ',') )
{
File >> Number;
File >> Comma;
File >> two;
File >> Comma;
File >> three;
File.get();
String^ ShowThis = gcnew String(two.c_str());
MessageBox::Show(ShowThis);
}