Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format specifier in scanf for bool datatype in C

Tags:

I am using bool datatype in C std99 whose definitions are defined in <stdbool.h>. Now I want the user to give me input. What format specifier I must use in scanf to input the boolean value of 1 byte from the user and then manipulate it afterwards in my program.

like image 426
pranavk Avatar asked Oct 16 '12 18:10

pranavk


1 Answers

There is none.

Use a temp object as the size of _Bool is implementation dependent.

#include <stdbool.h> #include <stdio.h>  bool b; int temp;  scanf("%d", &temp); b = temp; 
like image 196
ouah Avatar answered Sep 19 '22 14:09

ouah