ですが、やってることは分かっているのにループの順番が不明瞭です。
<実行例>
./main
Enter words : aaa bbb
i=0, "aaa"=3
i=1, "bbb"=3
<プログラム>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define WORDLEN 64
#define WORDNUM 200
#define IN 1
#define OUT 0
int readword(char word[WORDLEN]){
char cc ;
int i, flag ;
flag = OUT ;
i=0;
while(!feof(stdin)) {
cc = getchar() ;
if (isalpha(cc) || isdigit(cc)){ /* you may use "isalnum()" */
flag = IN ;
word[i] = cc ;
i++ ;
if (i >= WORDLEN)
return 0 ;
}
else if (flag == IN){
word[i] = '\0' ;
return i ;
}
}
return EOF ;
}
int main(void){
char words[WORDNUM][WORDLEN] ;
int i, j ;
int lengh ;
i=0;
printf("Enter words : ") ;
while (!feof(stdin)){
lengh = readword(words[i]) ;
printf("%d",lengh);
if (lengh == 0)
printf("No more space in readword !!!\n") ;
/* Normally, you shold use fprintf(stderr, ....) at caution. */
else if (lengh == EOF)
printf("End of file!!!\n") ;
else {
printf("i=%d, \"%s\"=%d\n", i, words[i], lengh) ;
i++;
}
}
printf("Dump stored words : \n") ;
for (j = 0 ; j < i ; j++)
printf ("%d:%s\n", j, words[j]) ;
printf("\nBye....\n") ;
return 0 ;
}