Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string getFilePath(const char& ioVar) {
- std::string filePath = "";
- if (ioVar == 'i') {
- std::cout << "\nEnter the path to the input file: ";
- std::cin.clear(); //clears the stream if ^z is pushed
- getline(std::cin, filePath);
- //if the input is clear -> read information from in.txt from the root folder
- if (filePath.empty())
- filePath = "D:/Studying/Programming/LABS/Laboratory Work 2.3 v.1/Laboratory Work 2.3 v.1/in.txt";
- //if user didn't provided full adress -> find the file in the root folder
- else if (filePath.find('\\') == std::string::npos and filePath.find('/') == std::string::npos)
- filePath += ".txt";
- } else {
- std::cout << "\nEnter the path to the output file: ";
- std::cin.clear();
- getline(std::cin, filePath);
- //if file path is empty -> save the output to the out.txt in the root folder
- if (filePath.empty())
- filePath = "D:/Studying/Programming/LABS/Laboratory Work 2.3 v.1/Laboratory Work 2.3 v.1/out.txt";
- //if user didn't provided full adress -> create a new file in the root folder
- else if (filePath.find('\\') == std::string::npos and filePath.find('/') == std::string::npos)
- filePath += ".txt";
- }
- return filePath;
- }
Advertisement
Add Comment
Please, Sign In to add comment