What would be the format specifier while printing the value of a bool variable in C99? I am using MinGW compiler in Code Blocks.
What would be the format specifier while printing the value of a bool variable in C99? I am using MinGW compiler in Code Blocks.
Code:printf("%s", bool_variable?"true":"false");
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Thanks a lot...
And what would be the statement for reading a Boolean variable in C99?
Well, C99 would support int to bool conversion I would think.
You could also be clever like
bool toggle = strcmp( maybe, "true" ) == 0;
Actually I am inputting an adjacency matrix, so user can input only 0 and 1. I have defined the matrix as bool. So any idea please?
I don't see a problem. If you assign 1 or 0 to a bool, then it becomes true or false respectively. Read the number and then assign to a bool.
I am getting the following warning!Code:scanf("%d",&G[row][col]);
G:\PROJECT MATERIAL\Program (C)\Graph Isomorphism\main.c||In function `main':|
G:\PROJECT MATERIAL\Program (C)\Graph Isomorphism\main.c|61|warning: int format, _Bool arg (arg 2)|
||=== Build finished: 0 errors, 1 warnings ===|
Read to a temporairy int then copy it into the array.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
@King Mir
Thanks it worked! Simply but witty suggestion!