#include<stdio.h>
#include<string.h>
#include<ctype.h>
void GetWord(char *word){
int ch;
int cnt = 0;
char word_buff[20] = {0};
while(1){
ch = getchar();
if((isalnum(ch)) == 0)
break;
word_buff[cnt] = ch;
cnt++;
}
strcpy(word,word_buff);
}
int main(){
char word[20];
for(int i = 0; i < 10; i++){
GetWord(word);
printf("%s\n", word);
for(int j = 0; j < 20; j++)
word[j] = '\0';
}
return 0;
}
[sp]はスペースのことです。
テキスト内容「test.[sp]te[sp]ttte[sp]000,000[sp][sp][sp][sp]hu[sp]ih」
[実行結果]
test
te
ttte
000
000
hu
原因が分かる方がいたら回答よろしくお願いします。