| Author |
No boolean in C(What)?
|
Arjun Srivastava
Ranch Hand
Joined: Jun 23, 2010
Posts: 431
|
|
I was trying to make above code in C. And what i found boolean is not defined in C,sorry i was like What.
Ok fine let us C, i will use true and false as the string for testing.
Then i use keyword "string" as habitual of java,now string is also not there, undefined keyword.
You have to use to char [],now am pissed.
Finally i made it somehow.It's very difficult for me to learn C again after Java.
|
SCJP 6 | FB : Java Certifications-Help. | India Against Corruption
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2928
|
|
C doesnt provide an advanced API like Java does. Its always difficult to get back to a lesser advanced language coming from a high level language.
|
Mohamed Sanaulla | My Blog
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9952
|
|
most variables in C can be uses as booleans. 0 is considered false, and 'not zero' is considered true. You could have written this:
although, it's not clear if you want b=0 or b==0.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Arjun Srivastava
Ranch Hand
Joined: Jun 23, 2010
Posts: 431
|
|
fred rosenberger wrote:most variables in C can be uses as booleans. 0 is considered false, and 'not zero' is considered true.
Hi really thanks for the reply,
I have tried what you have advised,it works.
zero and non zero can be used inplace of boolean value.
C is still language of last decade for me, mixing Java and C, a tough job.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
|
Actually, C99 and later define a type "_Bool"; the header "stdbool.h" defines macros "bool", "true" and "false", which evaluate to "_Bool", "1", and "0", respectively. The more recent C++ standard includes an actual type "bool" and actual type literals.
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: No boolean in C(What)?
|
|
|