-1

I have a little program that I made which allows me to take in some text and sort it and make it look the way I want it to. One of my functions to save the new text file allows the user to input the name of the file using C++.

What I want to do is at the end of the program, I want it to open notepad displaying that new text file. I know you use " system("notepad.exe (txt file)")." But I can't add a string variable in place of the txt file. It requires the name of the text file, but the file name could be anything depending on the user.

Any help or a link to where I can read about it would be great! Thanks

jediderek
  • 309
  • 1
  • 11

1 Answers1

1

Assemble the command in a std::string and then use its c_str function to pass to system.

Neil Kirk
  • 21,327
  • 9
  • 53
  • 91
  • 1
    Downvote with no comment - nice. Nobody learns anything! – Neil Kirk Dec 05 '15 at 02:52
  • I was a little rusty with my c++(still consider myself a begginer) and was trying to figure out what you were trying to say. After testing, your method worked! Thank you so much sir for taking the time. – jediderek Dec 05 '15 at 03:53
  • Btw I wasn't the one who downvoted you, but I did upvote :D – jediderek Dec 05 '15 at 03:53