Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE [100]
- struct member{
- char word[20];
- };
- int main()
- {
- struct member *m;
- int i = 0, j = 0;
- FILE *f;
- f = fopen("C:\\english_word_test.txt", "r");
- while (fgetc(f) != -1)
- j++; //텍스트 파일 내 글자 갯수를 구합니다.
- m = (struct member*) malloc(sizeof(struct member) * j / 20); //글자 갯수에 따라 m의 크기를 정합니다.
- fseek(f, 0, 0); //다시 파일 처음부터 검사합니다.
- while (feof(f) == 0) {
- fscanf(f, "%s", &m[i].word);
- printf("%s \n", m[i].word);
- i++;
- }
- fclose(f);
- free(m); //할당해준 공간을 도로 가져갑니다. (해제합니다)
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement