Pagini recente » Cod sursa (job #498195) | Cod sursa (job #1461081) | Cod sursa (job #2430242) | Cod sursa (job #3296723) | Cod sursa (job #575186)
Cod sursa(job #575186)
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
class File {
FILE * mhFile;
public:
File (const char * aFileName, const char * aOpenMode)
{
mhFile = fopen (aFileName, aOpenMode);
}
~File ()
{
if (IsOpen())
{
fclose (mhFile);
}
}
bool IsOpen () const { return NULL != mhFile; }
operator FILE * () const { return mhFile; }
};
int main(int argc, char * argv[])
{
File fIn ("adunare.in", "r");
if (!fIn.IsOpen()) return 0;
File fOut ("adunare.out", "w");
if (!fOut.IsOpen()) return 0;
long a, b;
int nRead = fscanf (fIn, "%ld\n%ld", &a, &b);
if (2 != nRead) return 0;
int nWritten = fprintf (fOut, "%ld", a + b);
if (1 != nWritten) return 0;
return EXIT_SUCCESS;
}