while (1)
{
if (feof(text) != 0) //find EOF
{
puts("Reading Finished");
break;
}
tmp = fgetc(text); //check every character
if (tmp == ' '||tmp==NULL||tmp==' ') //find blank(Space-Bar)
{
fseek(text, -chCount, SEEK_CUR);
//move file cursor to head of a word
word = (char*)malloc(sizeof(char)*(chCount));
//dynamic allocation for single word
fscanf(text, "%s", word);
//store word from text.txt to char* word
printf("%d ", strlen(word));
//print length of word array(string)
puts(word);
vCount += checkBEv(word);
//check whether beV or not
free(word);
//delete array
chCount = 0;
//chCount means length of single word
//after checking word, clear it zero
fseek(text, 1, SEEK_CUR);
//for skip blank. IT IS NECESSARY!
}
chCount++;
//for skip blank. IT IS NECESSARY!
}
어케해야함?
파일 열때 fopen "rb" 로 열었어?
ㄴㄴ모드 r로함.. 설마 그거때매??
ㅇㅇ
rb로 바꿔도 그대로인데. 컴파일해보면 똑같은 지점에서 디버그에러터짐
fgetc로도 개행 읽을 수 있지 않나.. tmp=='\n'에서 왜 빵꾸가...
근데 개행이 연거푸 온다고 하면 단어수를 늘림?
난 t 모드(디폴트)로 읽으면 파일 위치가 직관적이지 않아서 아예 안씀. 항상 "rb"로 읽음.
음 엔터가 두번 연달아 터지는 부분에서 저모양이네 아마 if문 내부 수정이 필요할듯 일단 가르쳐줘서 ㄳ합네다.
텍스트파일 읽는거면 \10 \13
바보 13 10 이지. CR+LF는 DOS 호환인 경우고
그러네
http://dblack.tk
커뮤니티 사이트 입니다 많은 이용 부탁 드립니다.