• Post Reply Bookmark Topic Watch Topic
  • New Topic

for loop array problem  RSS feed

 
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RESOLVED

 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And apart from line 10 not compiling, what was the problem?
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:And apart from line 10 not compiling, what was the problem?



one of the most frustrating things you can do I forgot to a simple assignment easily overlooked haha
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very easily done. Did you get an error saying
Expected boolean, found int
or similar?
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:It is very easily done. Did you get an error saying
Expected boolean, found int
or similar?


Yes it said incompatible type cannot convert to boolean or something very similar
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have had lots of them. That particular message may be like that because in C/C++ you can use any non‑zero number and any non‑null reference as true and 0 or null as false, so you are allowed an int instead of a boolean. In fact, C doesn't actually have a boolean datatype.
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I have had lots of them. That particular message may be like that because in C/C++ you can use any non‑zero number and any non‑null reference as true and 0 or null as false, so you are allowed an int instead of a boolean. In fact, C doesn't actually have a boolean datatype.


Yeah I have no clue why that error would come up,I thought I would have just got an error that pointed out I forgot an operator.

and wow really??? that took me a bit of guard C/C++ does not use the boolean data type? what would there way around that be
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ready told you. C uses any non‑zero integers for true. Zero or null for false.
C++ does actually have a bool datatype, but can still use numbers for booleans.
Java® only uses booleans or Booleans for true and false.
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I ready told you. C uses any non‑zero integers for true. Zero or null for false.
C++ does actually have a bool datatype, but can still use numbers for booleans.
Java® only uses booleans or Booleans for true and false.


That's pretty cool actually,I'm moving onto C and C++ next year in my final year of college.this will be fun haha
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!