I need to check in my program if the user entered a character in an integer field.
example:
int years;
printf("Enter number of year\n');
scanf("%i", %26amp;years);
if (this is what i dont know) // I need to see if the user entered text here and give an error
{
printf("You entered text in an integer field!\n);
while (this is what i dont know again.) //same as if statement
{
printf("Enter Years again this is a number!\n");
scanf("%n", %26amp;years);
}
}
Any help is appreciated.
Question about a conditional statement comparing data types in C programming?
I thought I could help but thats beyond me.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment