I need to scan for the following input type using C:
number letter number
so i used the follwing:
scanf("%d%c%d", &n1, &lett, &n2);
Unfortunately with this, whenever I attempt to input a single number and press enter, scanf continues to expect another input. How can I adjust the program so that the user must enter the correct format first go.
I tried:
if (scanf("%d%c%d", &n1, &lett, &n2) == 1) {
...program...
} else {
printf("Please enter correct format");
}
but didnt work
Thanks, new to programming