The following code does not work... could someone explain?
char StringFromFile[10];
char ConstantString[10] = "RootFolder";
//This is a Win32 Application. I can't remember the parameters
//for int Main.... but I'm sure you get the idea.
int Main()
{
ifstream DataSource("Dat.txt");
DataSource.getline(StringFromFile, 10);
if (StringFromFile == ConstantString)
{
MessageBox(NULL, StringFromFile, "Just a test", MBOK);
}
else
{
MessageBox(NULL, "The text did not match", "Just a test", MBOK);
}
return 0;
}
The problem is that the comparison always returns false and displays the "The text did not match" messagebox...
Is it because the line read has a newline character? I'm not sure how to remove it if this is the case. Any advice?