As the title suggest i'm coding at late o'clock over here and My code just hangs. I'm sure its something simple but I'd like to get it before bed.
thanks.Code:/* my getWord.c GetWord reads characters from stdin up until the first space. it stores it in its argument a char * and appends a '\n' then returns the word */ #include <stdio.h> #include <string.h> #define STOP ' ' #define SIZE 100 char *GetWord(char *); int main(void){ char store[SIZE]; char *word = GetWord(store); printf("The word is %s", word); getchar(); return 0; } char *GetWord(char vault[]){ int ch,ndx=0; while( (ch = getchar()) !=STOP || ch !=EOF){ vault[ndx] = ch; ndx+=1; } vault[ndx] = '\0'; while(getchar() !='\n'); return vault; }



LinkBack URL
About LinkBacks



it I was drinking i'd have an excuse. right now its just lack of sleep. Thanks again.