Calling a console command with user input filename?

hey guys, just a hint I need.

I ask the user to input a name for a file and I store it in a location on the drive.

But now I need to call a console command 16-bit based with that file.

the code i wrote is the following:

1
2
3
4
5
cout << endl << "Please enter the desired file name to continue: ";
cin >> filename;
fname.open(filename + ".txt");
// system ("prn2file.com filename");
fname.close();



In the comment is my question..how do I enter to be executed the input specified filename??
Last edited on
Hmm.. you could do this

1
2
3
4
5
6
cout << endl << "Please enter the desired file name to continue: ";
cin >> filename;
fname.open(filename + ".txt");
string command = "prn2file.com " + filename + ".txt";
system (command.c_str());
fname.close();
Hi,

thanx for replying and excuse me for getting back to you so late...

This works really well, but my problem is that c_str() provides a termination signal and the program exits and that I do not like at all.

Is there any other way to do this without the termination signal.
I saw that data() does not provide a termination signal but after a check it did exit the program.

Thank you in advance.
Topic archived. No new replies allowed.