Mail Archives: djgpp/1998/08/01/04:33:07
*********** REPLY SEPARATOR ***********
On 98-08-01, at 02:52, A.S.A. Inc. wrote:
>GIVE ME YOUR HELP!!!!
>
>
>What's Wrong????
>
>
>main(int argc,char *argv[])
>{
>ScreenClear();
>puts(argv[1]);
>
>if (argv[1]=='the') printf("OK"); ----> Problens with IF
>else printf("Wrong");
>
>getchar();
>exit(0);
>}
if (argv[1]=='the') printf("OK");
1. 'the' is not a string. It's an integer multi-character constant. Should be "the".
2. This lines compares not the strings, but pointers to them.
This should work.
main(int argc,char *argv[])
{
ScreenClear();
puts(argv[1]);
if (strcmp(argv[1], "the")==0) printf("OK");
else printf("Wrong");
getchar();
exit(0);
}
Pawel Kowalski
- Raw text -