djgpp functions returning boolean?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
OSNewbie

djgpp functions returning boolean?

Post 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
carbonBased

RE:djgpp functions returning boolean?

Post 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
OSNewbie

RE:djgpp functions returning boolean?

Post 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... :)
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

RE:djgpp functions returning boolean?

Post by df »

a function like.. strcmp?
-- Stu --
Post Reply