Sorry, the thread title should read "File paths with spaces"
Hello everyone. I am finalizing this little shift cipher program that reads a plain text file line by line, encrypts it, and writes it to a cipher text file. I'm just having difficulty when a user enters file paths with spaces. When this happens with the first file path request, the next one is skipped, and the user is asked to enter the shift value. Any help would be very appreciated.
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[]){
int shiftValue = 0;
string plainLine = "";
string inputPath = "";
string outputPath= "";
ifstream plainText(inputPath.c_str());
ofstream cipherText(outputPath.c_str());
cout << "Input Path: ";
cin >> inputPath;
cout << endl;
cout << "Output Path: ";
cin >> outputPath;
cout << endl;
cout << "Shift Value = ";
cin >> shiftValue;
cout << endl;
while (!plainText.eof()){
int lineLength;
getline(plainText, plainLine);
lineLength = plainLine.length();
int decimalValue[lineLength];
char cipherLine[lineLength];
for (int i=0; i<=lineLength; i++){
decimalValue[i] = (int)plainLine[i] + shiftValue;
cipherLine[i] = (char)decimalValue[i];
cipherText << cipherLine[i];
}
cipherText << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}