www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/01/04:33:07

Message-ID: <199808011034540560.0020E8AA@pogwizd.tcs.uni.wroc.pl>
In-Reply-To: <35BFFED0.459E@hotmail.com>
References: <35BFFED0 DOT 459E AT hotmail DOT com>
Date: Sat, 01 Aug 1998 10:34:54 +0200
From: "Pawel Kowalski" <pk AT tcs DOT uni DOT wroc DOT pl>
To: a_azevedo AT hotmail DOT com, djgpp AT delorie DOT com
Subject: Re: A DOUBT LOOK THIS
Mime-Version: 1.0


*********** 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019