http://gall.dcinside.com/board/view/?id=programming&no=495034&page=2 아까 이글에서 엔터는 포기..
while (1)
{
tmp = fgetc(text); //check every character
if (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!
if (tmp == '\0' || feof(text) != 0) //find EOF
{
puts("Reading Finished");
break;
}
}
중간에 엔터 없이 Joseph R. “Beau” Biden III, the former Delaware Attorney General and son of Vice President Joe Biden, died at 46 after battling brain cancer, the Vice President’s office announced Saturday night. 라는 문장을 그대로 읽어들이는데
다 잘 되는데 맨 끝의 night.부분을 그냥 스킵해버리네.. nignt. <-이렇게 스페이스바 한칸 해주면 night.도 인식은 하는데.. 이를 어쩌면 좋습니까..
ㅋㄷㅋㄷ 딜리미터 단위로 처리하게 했으니 당연하지.
그럴땐 파일 통째로 읽고 파일 끝에 강제 삽입하는것도 방법.
fseek, ftell, 동적 할당, fread 한방에 읽고 마지막에 딜리미터 강제 추가. 이 루틴 돌림. 끝.
tmp == ' ' 를 tmp == ' ' || tmp == EOF로 고칠 것.
그럼 됨.
아마도. (그냥 눈 코딩 ㅋㄷ)
그렇게까지 안해도 생각해보면 니 코드 선에서 해결할 방법 많음~ 생각해보시오~
ㅅㅅㅅ// 그러니 폭발해버림..
난 분기 늘어나는것 보단 예외를 미리 소거하는걸 즐겨. 고속 알고리즘 만들기 위해서.
프로그램//아 모드 a로해서 덧붙여쓰기로 스페이스바 추가? ㄳㄳ
사실 글쓴이가 쓴 방법은 좀 더럽고 깔끔하게 하려면 fre\0ad()로 먼저 파일을 쫙 다 읽고 str\0tok\0_\0r() 써서 문자열 분리시키는 거.
http://autogram.tk/이
중고차 어플리케이션 어떤가요?