Format specifier in scanf for bool datatype in C
问题 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. 回答1: 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; 来源: https://stackoverflow.com/questions/12920694/format