Cod sursa(job #758558)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max 50
int main(){
FILE *in, *out;
char *numein, *numeout, *number;
int numb_1,numb_2;
numein = (char*) malloc(max * sizeof(char));
numeout = (char*) malloc(max * sizeof(char));
number = (char*) malloc(max * sizeof(char));
scanf("%s%s", numein, numeout);
if((in = fopen(numein,"r")) == NULL ){
printf("It doesn't exists");
return -1;
}
if ((out = fopen(numeout,"w")) == NULL ){
printf("It doesn't exists");
return -2;
}
fgets(number, max, in);
number = strtok(number,"\n");
sscanf(number,"%d",&numb_1);
fgets(number, max, in);
number = strtok(number,"\n");
sscanf(number,"%d",&numb_2);
numb_1 = numb_1 + numb_2;
numb_2 = sprintf(number,"%d",numb_1);
fputs(number,out);
fclose(in);
fclose(out);
return 0;
}