Created
September 21, 2012 17:18
-
-
Save Yi-Tseng/3762731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include <string.h> | |
#include<stdlib.h> | |
#include <sys/stat.h> | |
int main(){ | |
FILE* file_a; | |
FILE* file_b; | |
FILE* file_c; | |
char buffer[1024]; | |
file_a = fopen("a.txt", "r"); | |
file_b = fopen("b.txt", "r"); | |
file_c = fopen("c.txt", "a"); | |
if(file_a == NULL || file_b == NULL || file_c == NULL){ | |
printf("!!!\n"); | |
return -1; | |
} | |
while(fgets(buffer, 1024, file_a)!=NULL){ | |
size_t len = strlen(buffer); | |
printf("%lu %s\n",len,buffer); | |
fprintf(file_c, "%s\n",buffer); | |
} | |
while(fgets(buffer, 1024, file_b)!=NULL){ | |
size_t len = strlen(buffer); | |
printf("%lu %s\n",len,buffer); | |
fprintf(file_c, "%s\n",buffer); | |
} | |
fclose(file_a); | |
fclose(file_b); | |
fclose(file_c); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment