C / C++ Code Portfolio



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

using namespace std;

// maximum line size


const int BUFFER = 512;

void MergeAndDisplay(ifstream files[], size_t count)
{
// declare a boolean indicating whether at least one file is still open to read lines from
bool atLeastOneFileOpen = true;
// declare a char array to store the text from one line
char temp[BUFFER];
// declare a boolean indicating whether a new line was the last text output
bool newLineWasLastOutput = true;
// while at least one file is open (i.e. while not all files are closed)
while (atLeastOneFileOpen)
{
// begin with the assumption that no files are open
// if it turns out a file is in fact open, this boolean will get set to true
atLeastOneFileOpen = false;
// for each file
for (int currentFile = 0; currentFile < (int)count; ++currentFile)
{
// if the file is open
if (files[currentFile].is_open())
{
// get the next line from the file
files[currentFile].getline(temp, sizeof(temp));
// if an EOF was not encountered in the file
if (!files[currentFile].eof())
{
// if the line that was read in from the file contains only a new line character
if (!strlen(temp))
{
// print out a new line character
cout << "\n";
// indicate that the last thing output was a newline
newLineWasLastOutput = true;
}
// if a new line was not the last thing output to the console
if (!newLineWasLastOutput)
{
// output a new line
cout << "\n";
}
// output the line from the file
cout << temp;
// indicate that the last thing output was not a newline
newLineWasLastOutput = false;
// indicate that at least one file is still open
atLeastOneFileOpen = true;
}
// if an EOF was encountered in the file

Download 112,15 Kb.

Do'stlaringiz bilan baham:
1   ...   8   9   10   11   12   13   14   15   ...   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