Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No boolean in C(What)?

 
Arjun Srivastava
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12127
30
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Arjun Srivastava
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic