Hi folks, just a queary about checking chars. I have a char[] variable. I ask the user a question and the user types a response and presses enter. I need to check the variable to see if it said particular things and more importantly if it said nothing.
#include <iostream>
#include <fstream>
using namespace std;
char _cFileName[100];
int main()
{
cout<<"Enter the name of the file to open or press enter for HELP: ";
cin>>_cFileName;
if(_cFileName == 'HELP')
{
cout<<"DISPLAY HELP FILE"<<endl;
system("PAUSE");
return 0;
}
if(_cFileName == '')
{
cout<<"DISPLAY HELP FILE"<<endl;
system("PAUSE");
return 0;
}
ifstream infile("data.txt");
cout<<"Your file is "<<sizeof(infile)<<" bytes."<<endl;
system("PAUSE");
return 0;
}
Apparently using either "HELP" or 'HELP' or HELP when using the if statement does not work. So I am just wondering where I am going wrong. Perhaps chars are not the way to go when doing this?
Also as an aside. I have not had a chance to test this yet, but does sizeof() work on streams?
Any help is much appriciated.