So, I have a printf
, that asks for the users middle initial, then I have a scanf
under that, then I output the users middle initial. My problem is that my printf
is displaying after my scanf
C Code
#include <stdio.h>
#include <string.h>
int main(void) {
char middleInitial;
printf("What is your middle initial? ");
scanf(" %c", &middleInitial);
printf("Middle initial %c", middleInitial);
}
So as you can see, there are two printf
's. My scanf
is running before my first printf
displays the question.
Example (This is what I'm getting in my terminal)
$ ./a.exe
c
What is your middle initial? Middle initial c
What I want
$ ./a.exe
What is your middle initial? c
Middle initial c
By the way, the c is what the user inputs