www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/03/11/02:28:52

From: kunst AT prl DOT philips DOT nl (Pieter Kunst)
Subject: Re: STRCMP (problem?)
To: ckgp!thomas AT uunet DOT uu DOT net
Date: Thu, 11 Mar 93 8:22:07 MET
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (DJGPP users list)
Mailer: Elm [revision: 70.30]

Michael Thomas writes:

>    I noticed something strange and was wondering if anyone else has
>    noticed this? when using strcmp the result numbers are about 46
>    so
> 
>    stat = strcmp("number","number");  stat == 46
>    stat = strcmp("number","number#");  also stat==46
>    stat = strcmp("is","what"); stat == 41
>    stat = strcmp("was","that"); stat == 55
> 
>    Isn't strcmp supposed to return numbers <0,=0,>0 as results?
>    When I noticed this I wrote a simple program to compare to strings
>    and print the result... then I thought that it might have something
>    to do with 2.3.3 so I loaded 2.2.2 again and the same thing happens...
>    I am running djgpp 1.09...
> 
>    any ideas? is this suposed to be like this... if so is 46 equivalent
>    to 0, and why do you think comparing number,number is the same as
>    comparing number,number# ?
> 
>    Any information would be great! Thanks...
>   

It sounds to me that you didn't include the correct prototype files
in your program. Add the following line at the start of your program:

    #include <string.h>

or else at least something like:

    int strcmp(const char *s1, const char *s2);

--

Pieter Kunst (kunst AT prl DOT philips DOT nl)

- Raw text -


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