Hi Everyone,
I need help with using isdigit in C. What I am trying to do is verify that the user input is numeric. In my program, as is, I get the error:
line (21) : error C2061: syntax error : identifier 'isdigit'. If I remove the "if" from in front of the" isdigit" it will run but not give me the results that I need. It runs thru the program as if it where 0 and goes to my
3rd "if" statement, printing the you have 18 years to wait to vote, then it prints "You did not enter a digit".
Here is my code;
/* CSS 561 Prograqmming Concepts
Week 2 Assignment
A program that prompts a user for his or her age,
and computes whether they are old enough to vote – age 18.
If they are too young, your program should inform them that
they can vote in XX years. If they are old enough, you should
inform them that they have been eligible to vote for YY years. */
//by Ken Volkman
#include <stdio.h>
#include <ctype.h>
int main()
{
int iResponse = 0;
char cResponse = '\0';
{
printf("\n\tThis program will determine if you are old enough to vote:\n");
printf("\n\tPlease enter your age; ");
scanf_s("%d, %c", &iResponse, &cResponse);
}
if isdigit(cResponse);
{
if(iResponse >=18)
{
printf("\n\tYou have been elgibale to vote for\n\t%d years now.\n\t", iResponse - 18);
//printf("\n\t");
printf("\n\t'Thank You'");
printf("\n\n\t");
}
if(iResponse < 18)
{
printf("\n\tYou are not old enough to vote yet, \n\tbut you will be eligable in %d years.\n", 18 - iResponse);
//printf("\n\t");
printf("\n\t'Thank You'");
printf("\n\n\t");
}
else
printf("\n\tYou did not enter a didgit\n\n\t");
}
}
Can someone please help me out?
Tyserman5674