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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]){
FILE *fp1;
FILE *fp2;
FILE *fp3;
char *p1;
char *p2;
char *p3;
int temp1;
int temp2;
int temp3;
int counter = 0;
char string1[100];
char string2[100];
char string3[100];
fp1 = fopen(argv[1], "r");
fp2 = fopen(argv[2], "r");
fp3 = fopen(argv[3], "r");
while(p1 = fgets(string1, 100, fp1) && p2 = fgets(string2, 100, fp2) && p3 = fgets(string3, 100, fp3)){
if(p1 == NULL || p2 == NULL || p3 == NULL){
counter++;
}
if(counter>2){
break;
}
sscanf(string1, "%d", &temp1);
sscanf(string2, "%d", &temp2);
sscanf(string3, "%d", &temp3);
printf("%d\n%d\n%d\n", temp1, temp2, temp3);
}
fclose(fp1);
fclose(fp2);
fclose(fp3);
return 0;
}
|