What is the printf format specifier for bool in C

2 Answers

0 votes
#include <stdio.h>
#include <stdbool.h>

int main() {
	bool b = true;

	printf("%d\n", b); 
	
	b = false;
	printf("%d\n", b); 
}




/*
run:
  
1
0
 
*/

 



answered Jul 14, 2020 by avibootz
0 votes
#include <stdio.h>
#include <stdbool.h>

int main() {
	bool b = true;

	printf("%s", b ? "true\n" : "false\n");
}




/*
run:
  
true
 
*/

 



answered Jul 14, 2020 by avibootz

Related questions

2 answers 349 views
349 views asked May 18, 2015 by avibootz
1 answer 135 views
1 answer 140 views
140 views asked Aug 28, 2023 by avibootz
...