So I have to code a function that will get the next word from the standard output and this is what I have. It need to skip any leading character that is non-alphanumeric. return the word or null of it find EOF. the thing is I am in a endless loop, it never returns NULL. Any help will be greatly appreciated
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
char buf[MAXBUF];
int c;
int x = 0;
do {
c = getchar();
} while(!isalnum(c));
while(c != EOF){
if(isalnum(c)){
buf[x] = c;
x++;
c = getchar();
} else {
return make_string(buf, x);
}
}
return NULL;