C / C++ Code Portfolio



Download 112,15 Kb.
bet10/30
Sana01.03.2022
Hajmi112,15 Kb.
#475852
1   ...   6   7   8   9   10   11   12   13   ...   30
Bog'liq
dddd

if (!count)
{
cerr << "No files were specified\n";
exit(EXIT_FAILURE);
}
// dynamically allocate memory to store the information for each file to open
// if allocation fails, output an error message and exit
ifstream *files;
if ((files = new (nothrow) ifstream[count]) == NULL)
{
cerr << "Unable to allocate memory\n";
exit(EXIT_FAILURE);
}
// for each file to open...
for (int currentFile = 0; currentFile < (int)count; ++currentFile)
{
// open the file
files[currentFile].open(fileNames[currentFile]);
// if the file fails to open...
if (!files[currentFile].is_open())
{
// output an error message describing which file didn't open
cerr << "\"" << fileNames[currentFile] << "\": Failed to open\n";
// for each file that successfully opened before the file that failed to open...
for (; currentFile >= 0; --currentFile)
{
// close the file
files[currentFile].close();
}
// delete the file information allocated memory
delete files;
exit(EXIT_FAILURE);
}
}
return files;
}
// This function appends data from one file to the end of another file

#include

// AppendFile opens the file described by outFile and appends the file described by inFile to the end of it
int AppendFile(const char *inFile, const char *outFile)
{
FILE *fileToBeAppendedTo, *appendData;
// open the file to be appended to in write-only append mode
// open the file containing the data to append in read-only mode
if ((fileToBeAppendedTo = fopen(outFile, "ab")) == NULL)
{
// if file doesn't open for some reason, print an error message and quit
fprintf(stderr, "***ERROR*** AppendFile: Could not open outFile\n\n");
return -1;
}
else if ((appendData = fopen(inFile, "rb")) == NULL)
{
// if file doesn't open for some reason, print an error message and quit
fprintf(stderr, "***ERROR*** AppendFile: Could not open inFile\n\n");
fclose(fileToBeAppendedTo);


Download 112,15 Kb.

Do'stlaringiz bilan baham:
1   ...   6   7   8   9   10   11   12   13   ...   30




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish