Cod sursa(job #758558)

Utilizator RoxanaIstrateIstrate Roxana RoxanaIstrate Data 15 iunie 2012 23:19:03
Problema A+B Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.82 kb
 #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;
}