Can someone please help me with this code:
Code:
int validateSectionLetter(char c)
{
if (!isalpha(c))
{
printf("\n** You entered an invalid section. Please enter a section from A to Y. **\n\n");
return 0;
}
else if ((c = 'Z') || (c= 'z'))
{
printf("\n** You entered an invalid section. Please enter a section from A to Y. **\n\n");
return 0;
}
return c;
}
char enterSectionLetter()
{
char c = 0;
do
{
printf("Enter Section [A - Y]: ");
scanf("%d", &c);
}
while(!validateSectionLetter(c));
printf("The section is: %c", &c);
return c;
}
When I compile, if I enter a wrong character it will loop and writing the appropriate message, but when I enter a correct character like 'a' the .exe goes crazy.
Thank you in advance.