#include <stdio.h>

int main() {
     // 파일 열기 
     // FILE * 포인터이름 = fopen(파일이름, 파일모드);
     FILE * fp = fopen("test.txt", "a");

     // fputs 문자열을 파일에 쓰기
     // fputs(문자열, 파일포인터);
     fputs("\nfputs 함수를 이용해서 쓰는 중", fp);

     // 파일 닫기
     // fclose(파일포인터);
     fclose(fp);

     // r : 읽기 모드
     FILE * fp = fopen("test.txt", "r");

     // fgets 파일에서 문자열을 한 줄씩 읽기
     // fgets(변수이름, 최대크기, 파일포인터);
     char line[1000];
     fgets(line, 1000, fp);

     printf("%s", line);

     while (fgets(line, 1000, fp) != NULL) {
          printf("%s", line);
     }

     fclose(fp);

     return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: