#include <stdio.h>
void main()
{
FILE *fp[2], *fpw;
char arr[100]; // 파일에서 읽어들인 내용 저장할 배열
int i;
fp[0] = fopen("read.txt", "r"); // 읽을 파일명, 모드
fp[1] = fopen("write.txt", "r");
fpw = fopen("test.txt", "w");
for(i=0; i<2; i++)
{
while(fgets(arr, 100, fp[i]))
fputs(arr, fpw);
fputc('\n', fpw);
}
fclose(fp[0]); //파일 닫기
fclose(fp[1]);
fclose(fpw);
'프로그래밍. > C언어.' 카테고리의 다른 글
typedef란? typedef 사용법 (0) | 2011.03.28 |
---|---|
C언어 파일 입출력 (0) | 2011.03.28 |
구조체. ->연산자 .연산자 (0) | 2011.03.28 |
[C언어] 문자열 복사 함수 (strcpy, strncpy) 간단예제. (0) | 2011.03.28 |
문자열 비교 함수 (strcmp, strncmp) (0) | 2011.03.28 |