1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <stdio.h>
int main(void)
{
char t_str[8];
int t_int[4], i;
FILE *f_in = 0, *f_out = 0;
if(!(f_in = fopen("input.txt", "r")))
return 1;
if(!(f_out = fopen("output.txt", "w")))
{
fclose(f_in);
return 2;
}
while(fscanf(f_in, "%d %d %d %d : %[^\n]", &t_int[0], &t_int[1], &t_int[2], &t_int[3], t_str) == 5)
{
for(i = 0; i < 4; i++)
{
printf("%2d : %s\n", t_int[i], t_str);
fprintf(f_out, "%d : %s\n", t_int[i], t_str);
}
}
fclose(f_out);
fclose(f_in);
return 0;
} |
Partager