#include <cstdlib>
#include <cstring>
#include <iostream>
#include <stdio.h> //Adding libraries
using namespace std;
int main() {
bool endp = false;
FILE *fp, *rvr; // first file and second
char namefile[39];
char newname[30];
bool truef1 = true;
bool truef2 = true;
while (endp != true) // while true cases will happened
{
cout << "Check your number"
<< "\n 1 :: Create new file"
<< "\n 2 :: Create copy of previous file"
<< "\n 3 :: Create copy without spaces"
<< "\n 4 :: merge 2 files"
<< "\n 5 :: Count number of charasters"
<< "\n 6 :: Quit" << endl;
int switcher;
cin >> switcher;
switch (switcher) {
case 1:
cout << "You checked 1\n Please write name for the file" << endl;
char asd[100], finishname[40];
strcpy(finishname, "");
while (truef1) // for writing names of files within spaces until selectin
// Enter
{
cin >> namefile;
if (cin.get() == '\n') {
truef1 = false;
cout << "It's working!";
}
strcat(finishname, namefile);
strcat(finishname, " ");
}
truef1 = true; // for returning if you will select case 1 again
strcpy(asd, "C:\\Intel\\");
strcat(asd, finishname);
strcat(asd, ".txt");
fp = fopen(asd, "w");
fclose(fp);
strcpy(asd, "");
cout << "End of 1" << endl;
break;
case 2:
cout << "Copying the file \n please write filename of copying file "
<< endl;
char newname[30], finishnewname[80], copyr[40], finishcopy[80];
while (truef2) {
cout << "Please write name of file from which have you like take copy"
<< endl;
cin >> copyr;
if (cin.get() == '\n') {
truef2 = false;
cout << "It's working" << endl;
}
strcat(finishcopy, copyr);
}
truef2 = true;
cout << "Please write name of copy file " << endl;
while (truef2) {
cin >> newname;
if (cin.get() == '\n') {
truef2 = false;
cout << "It's working!";
}
strcat(finishnewname, newname);
strcat(finishnewname, " ");
}
truef2 = true;
char qwe[100], zxc[100];
strcpy(qwe, "C:\\Intel\\");
strcat(qwe, finishnewname);
strcat(qwe, ".txt");
rvr = fopen(qwe, "w");
strcpy(zxc, "C:\\Intel\\");
strcat(zxc, finishcopy);
strcat(zxc, ".txt");
fp = fopen(zxc, "r");
if (!fp)
cout << "Error" << endl;
while (!feof(fp))
fputc(fgetc(fp), rvr);
cout << "End of 2\n\n";
fclose(rvr);
fclose(fp);
break;
case 3:
cout << "End of 3";
break;
case 4:
cout << "End of 4";
break;
case 5:
cout << "End of 5";
break;
case 6:
cout << "Quit end of programm,Good bue" << endl;
endp = true;
break;
default:
cout << "Wrong input, let's try again";
break;
}
}
}
我没有找到我失踪的人。情况1应该在给定名称中添加目录一个文件。 接下来在案例2中我应该复制任何位于英特尔目录中的文件,但是在工作过程中,他给我的错误是文件不是激动并创建空文件。案例2应将所选文件的内容复制到其他文件。我没有找到我失踪的人。请帮帮我。