Page 1 of 1

djgpp functions returning boolean?

Posted: Sun May 04, 2003 11:00 pm
by OSNewbie
hi, i am writing a function compareStrings(char *str1, char *str2) in c with djgpp and i am wondering if i can have it return a boolean, or does it have to return an unsigned char or something? i would like to be able to do the following:

if (compareStrings("pssWRD", inputPwd))

if compareStrings() returns an unsigned char, then if the return value is 0 will the if statement evaluate to false and if the return value is any nonzero value will that if statement evaluate to true?

thanks

RE:djgpp functions returning boolean?

Posted: Sun May 04, 2003 11:00 pm
by carbonBased
Typically people try to learn the C language _BEFORE_ developing their OSs in it...!

C has no notion of a boolean data type, really... they can be any numeric value, be in char, short, long, etc... and either signed or unsigned, it makes no difference.

0 = false
!0 = true
Ergo, yes, your last statement is correct.

Cheers,
Jeff

RE:djgpp functions returning boolean?

Posted: Sun May 04, 2003 11:00 pm
by OSNewbie
ok, thanks that will work great then. and yes, i am realizing that learning c before making an os would have helped, but oh well, i am doing both at the same time! i used to do asm but wanted to convert, so this whole project is one big learning experience... :)

RE:djgpp functions returning boolean?

Posted: Mon May 05, 2003 11:00 pm
by df
a function like.. strcmp?