c언어 파일 입출력

C# 2014. 10. 7. 22:59

출처 : http://ra2kstar.tistory.com/53

#include <stdio.h>

int main(){

        FILE *fp ;

        int index;

        int data;


        fp = fopen("test.txt", "w");

        for(index = 0 ; index < 10 ; index++){

                fprintf(fp, "%d\n", index);

        }


        fclose(fp);


        fp = fopen("test.txt", "r");


        while(fscanf(fp, "%d", &data) != EOF){

                printf("%d\n", data);


        }


        fclose(fp);

        return 0;

}



결과

$ ~/a.out
0
1
2
3
4
5
6
7
8
9


'C#' 카테고리의 다른 글

Head First C# 77page  (0) 2014.04.28

Head First C# 77page

C# 2014. 4. 28. 20:23

프로젝트 탭에 Publish Contacts가 없을시 


빌드 탭에  Contacts 개시 클릭 하여 경로 바탕화면 설정 마침



실행해보면 됨


'C#' 카테고리의 다른 글

c언어 파일 입출력  (0) 2014.10.07