Difference between r1.4 and the current
@@ -27,7 +27,40 @@
== 두 파일을 각각 열기 ==
{{{
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
char str[100][100] = { NULL, };
FILE* pf1, * pf2;
pf1 = fopen("input.txt", "r");
if (pf1 == NULL) perror("파일 열기 실패\n");
else {
printf("파일 열기 성공\n");
int i = 0;
while (feof(pf1) == 0) {
fgets(str[i], sizeof(str)/sizeof(str[0]), pf1);
i++;
}
}
fclose(pf1);
pf2 = fopen("output.txt", "w");
if (pf2 == NULL) perror("파일 열기 실패\n");
else {
printf("파일 열기 성공\n");
int i = 0;
while (str[i][0] != NULL) {
fputs(str[i], pf2);
i++;
}
}
fclose(pf2);
return 0;
}
}}}두 파일 동시에 열기 ¶
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main() { char str[100]; FILE* pf1, * pf2; pf1 = fopen("input.txt", "r"); pf2 = fopen("output.txt", "w"); if (pf1 == NULL) perror("파일 열기 실패\n"); else { printf("파일 열기 성공\n"); while (feof(pf1) == 0) fputs(fgets(str,sizeof(str),pf1), pf2); } fclose(pf1); fclose(pf2); return 0; }
두 파일을 각각 열기 ¶
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main() { char str[100][100] = { NULL, }; FILE* pf1, * pf2; pf1 = fopen("input.txt", "r"); if (pf1 == NULL) perror("파일 열기 실패\n"); else { printf("파일 열기 성공\n"); int i = 0; while (feof(pf1) == 0) { fgets(str[i], sizeof(str)/sizeof(str[0]), pf1); i++; } } fclose(pf1); pf2 = fopen("output.txt", "w"); if (pf2 == NULL) perror("파일 열기 실패\n"); else { printf("파일 열기 성공\n"); int i = 0; while (str[i][0] != NULL) { fputs(str[i], pf2); i++; } } fclose(pf2); return 0; }