Comparing String to Filecontents?
I'm very new to C/C++, and I'm currently using the C-Styled strings. I'm trying to compare it to the contents of a file, just so I understand how to do it in the future. What kind of a command would I use to compare?
Code:
using namespace std;
int main()
{
string user;
cout<< "Enter your desired username: ";
cin.getline( user, , '\n' );
ofstream a_file ( "files.txt" );
a_file<< user;
a_file.close();
ifstream b_file ( "files.txt" );
char user2[50];
if ( strcmp ( user, user2 ) == 0 )
cout<< "File appending successful!\n";
else
cout<< "Internal Error\n";
cin.get();
}
I know the code is VERY bad, but basically what I'm trying to do is compare char user[50] to the contents of files.txt which I was trying to store in char user2[50].
Thanks ahead of time, sorry about the stupid question I'm very new.