• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

No boolean in C(What)?

 
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic