mickey
16th February 2007, 21:30
hi, I coded this:
int main (int argc, char* argv[]) {
cout << argv[1] << endl;
if (argv[1] == "hi") cerr << " hello\n";
char* p = "hi";
if (p == "hi") cout << "hello\n";
at console I need to launch program so: program.exe hi
and I don't understand why cout prints 'hi' but the first if isn't executed. isn't argv an array of char* ??? then why then second if is executed???
thanks
int main (int argc, char* argv[]) {
cout << argv[1] << endl;
if (argv[1] == "hi") cerr << " hello\n";
char* p = "hi";
if (p == "hi") cout << "hello\n";
at console I need to launch program so: program.exe hi
and I don't understand why cout prints 'hi' but the first if isn't executed. isn't argv an array of char* ??? then why then second if is executed???
thanks