This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes C / C++ and the fly likes No boolean in C(What)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "No boolean in C(What)?" Watch "No boolean in C(What)?" New topic
Author

No boolean in C(What)?

Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432


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
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

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: 11152
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

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: 24183
    
  34

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No boolean in C(What)?
 
Similar Threads
preprocessor directives
Output for a Jave prog
while loop problem
Question about boolean short circuit
identifier