TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: david nugent
date: 1996-04-22 02:49:32
subject: Filename Expansion

FA> What really freaks me is that FALSE is defined as 0, so according to
 FA> that, are the next lines true or false ?

But these functions don't return boolean information. They return something
DIFFERENT, such as a result code, or a value useful for comparison.


 FA> strcmp("hello","hello");  hardly FALSE, but it is 0.

strcmp() returns a value which determines how each string compares. 0 means
equal, < 0 means the first string is "less" then the second in
the character set being used, > 0 means the opposite.  This return value
allows sorting routines, such as qsort(), to sort strings based on that
return code.


 FA> system("wontfindme.exe");  worse than FALSE ? :)

No, it returns a system-defined return code from the operating system, or
-1 if something went wrong. Exactly what the return code means is defined
by your environment, and whatever program you're running - it has nothing
to do with C.


 FA> ..or is this just a booboo, nobody wants to change ?

Not at all a booboo. Boolean information is too limited for most uses. If
you must use a boolean string compare, then define:

#define strequal(x,y)  (strcmp(x,y)==0)

and use the macro 'strequal()' in your code.


 FA> In both cases, and in most C functions if FALSE was defined !TRUE and
 FA> TRUE was defined 0, the returned results would make more sense.

And be of far more limited use.

It would "make sense", certainly, if those functions were defined
to return values that can be used in a boolean context, but they don't.

Regards,
David

--- MaltEd/2 1.0.b6
* Origin: Unique Computing Pty Limited (3:632/348)
SEEN-BY: 50/99 78/0 620/243 623/630 632/103 348 360 998 633/371 634/388 396
SEEN-BY: 635/301 502 503 544 639/252 711/401 409 410 413 430 808 809 932 934
SEEN-BY: 712/515 713/888 714/906 800/1 7877/2809
@PATH: 632/348 635/503 50/99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.