Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[C++] Combining Strings?
#1
I need to know how to put multiple previously declared strings together to form a system command in a console application. I can get a SINGLE "string" to work, but how can I have 3 put together, declared by input?

Also needs to work with other text that ISN'T declared by input.

This is what I have so far, don't bother commenting on it, I'm a complete noob to this.
Code:
char myArray[75];
    char myArray2[75];
    char myArray3[75];
    cout << "Please enter the directory of the first file to bind: ";
    cin.getline( myArray, 75, '\n');
    cout << "Please enter the directory of the second file to bind: ";
    cin.getline( myArray2, 75, '\n');
    cout << "Please enter the directory of the output file: ";
    cin.getline( myArray3, 75, '\n');
    system("copy /b", myArray, " + ", myArray2, myArray3);
    system("PAUSE");
    return EXIT_SUCCESS;
Reply
#2
I would do this:

Code:
string command;
command += "copy /b ";
command += myArray;
command += " + ";
command += myArray2;
command += " ";
command += myArray3;
system(command.c_str());
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)