What would be the format specifier while printing the value of a bool variable in C99? I am using MinGW compiler in Code Blocks.
Printable View
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");
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.
Read it in with %d.
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.
@King Mir
Thanks it worked! Simply but witty suggestion!