CPP_basics_6_Lesson/Task_3.cpp

40 lines
941 B
C++

/*
Íàïèñàòü ïðîãðàììó, êîòîðàÿ ñîçäàñò äâà òåêñòîâûõ ôàéëà (*.txt), ïðèìåðíî
ïî 50-100 ñèìâîëîâ â êàæäîì (îñîáîãî çíà÷åíèÿ íå èìååò ñ êàêèì èìåííî ñîäåðæèìûì).
Èìåíà ôàéëîâ çàïðîñèòü ó ïîëüëçîâàòåëÿ.
*/
#include <iostream>
int FillFileBySmth(std::string);
int Task_3()
{
std::cout << "\t\tTask #3" << std::endl;
std::string filename_1;
std::string filename_2;
int result = 0;
std::cout << "Enter name of the 1st text file without extension:\n";
std::cin >> filename_1;
std::cout << "Enter name of the 2nd text file without extension:\n";
std::cin >> filename_2;
filename_1 += ".txt";
filename_2 += ".txt";
result = FillFileBySmth(filename_1);
if (result != 0)
{
std::cerr << "Something wrong with file creation in Task #3." << std::endl;
return result;
}
result = FillFileBySmth(filename_2);
std::cout << "________________________________________________\n\n";
system("pause");
system("cls");
return result;
}