-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopyFile.cpp
More file actions
41 lines (39 loc) · 827 Bytes
/
copyFile.cpp
File metadata and controls
41 lines (39 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "pthread.h"
#include "iostream"
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "bits/stdc++.h"
#include "ctime"
#include "cstdlib"
#include <fstream>
using namespace std;
int main()
{
char ch, sourceFile[20], targetFile[20];
FILE* fs, * ft;
cout << "Enter the Name of Source File: ";
cin >> sourceFile;
fs = fopen(sourceFile, "r");
if (fs == NULL)
{
cout << "\nError Occurred!";
}
cout << "\nEnter the Name of Target File: ";
cin >> targetFile;
ft = fopen(targetFile, "w");
if (ft == NULL)
{
cout << "\nError Occurred!";
}
ch = fgetc(fs);
while (ch != EOF)
{
fputc(ch, ft);
ch = fgetc(fs);
}
cout << "\nFile copied successfully.";
fclose(fs);
fclose(ft);
cout << endl;
}