I want to input data by format "%d:%c"
I have this:
#include <stdio.h>
int main() {
int number;
char letter;
int i;
for(i = 0; i < 3; i ++) {
scanf("%c:%d", &letter, &number);
printf("%c:%d\n", letter, number);
}
}
I expect this:
Input: "a:1"
Output: "a:1"
Input: "b:2"
Output: "b:2"
Input: "c:3"
Output: "c:3"
But my program doing something like this:
a:1
a:1
b:2
:1
b:2
--------------------------------
Process exited with return value 0
Press any key to continue . . .
What is the problem here?