Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Kevin Pham
- //Lab 04 CIS22A
- //This lab shows us how to copy a file from a folder to copy and save it into another or same folder.
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream inputFile;
- ofstream outputFile;
- string temp;
- string filenameIn;
- string filenameOut;
- int i = 1;
- while (i)
- {
- cout << "Please enter a FILE NAME:"; //Type out the File you want to copy for example: FILE NAME.txt
- getline(cin, filenameIn);
- inputFile.open(filenameIn);
- if (inputFile.fail())
- {
- cout << "Please try again, Invalid Input... " << endl;
- }
- else
- {
- i = 0;
- }
- }
- i = 1;
- while (i) {
- cout << "Please enter the destination FILE NAME: ";//File Destination: H:\Visual Studio 2017\Projects\Examples/ FILE NAME.txt
- getline(cin, filenameOut);
- outputFile.open(filenameOut);
- if (outputFile.fail())
- {
- cout << "Please try again, Invalid Input... " << endl;
- }
- else {
- i = 0;
- }
- }
- getline(inputFile, temp);
- outputFile << temp << endl;
- inputFile.close();
- outputFile.close();
- cout << "Your Done!! Its Copied..." << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement