First scanf
read the entered string and left behind \n
in the input buffer. Next call to scanf
read that \n
and store it to character
.
Try this
scanf (" %c", &characte);
// ^A space before %c in scanf can skip any number of white space characters.
Program will not work for strings more than one character because scanf
stops reading once find a white space character. You can use fgets
instead
fgets(string, 200, stdin);