I just recently starts learning C and found a problem. So here is my code:
#include <stdio.h>
#include <ctype.h>
int main()
{
char email[100];
int i;
printf("Input username (email) :");
scanf("%s", email);
for (i = 0; email[i] != '\0'; ++i)
{
if(!ispunct(email[i]))
{
printf("Please input a correct username (email) :");
scanf("%s", email);
}
}
return 0;
}
So, the program somehow only finished if I only input 1 character like @ or other punctuation, but if I add alphabet like jack@gmail.com it will loop forever until I input only 1 punctuation. so can somebody please tell me whats wrong? I am trying to make a program that will only loop if I only input alphabet and didn't input punctuation like @ or . in my email.