Code:
char line[100];
if (scanf("\t%99[a-zA-Z]\t", line) != 1)
return 1;
it will eat all space chars and take all letters
" 1234" - exit
" abcd1234" - take abcd
also you can get an all string and then do strpbrk for numbers
Code:
if (strpbrk(line, "0123456789") != NULL)
return 1;
but you will get punctuation like it is valid (id est if you need punctuation it will be ok and if not so ...)
if you want most reliable check, you would use isalpha() (because it will exclude all other chars, unless a-zA-Z)
Code:
#include <string.h>
/* OnlyLettersLine: check line l for letters only */
int OnlyLettersLine(const char *l)
{
if (l == NULL || *l == '\0')
return EOF;
while (*l != '\0')
if (!isalpha(*l++))
return 0;
return 1;
}
if (OnlyLettersLine(line) != 1)
return 1;
example for this function