The %c
conversion specifier in the format string of scanf
does not skip (read and discard) the leading whitespace characters. If you have a leading whitespace character in the format string, then this means scanf
will skip any number of leading whitespace characters in the input which is probably what you want. Assuming you want to read a single character -
char idade;
scanf(" %c", &idade);
// ^ note the leading space
However, if you want to read an input string from stdin
, then
char input[50+1]; // max input length 50. +1 for the terminating null byte
// this skips any number of leading whitespace characters and then
// reads at most 50 non-whitespace chars or till a whitespace is encountered -
// whichever occurs first, then adds a terminating null byte
scanf("%50s", input);
// if you want to read a input line from the user
// then use fgets. this reads and stores at max 50 chars
// or till it encounters a newline which is also stored - whichever
// occurs first, then it adds a terminating null byte just like scanf
fgets(input, sizeof input, stdin);
Please read the man page of fgets.