简体   繁体   中英

Running C++ program and Notepad

How to open a notepad in C++ then still continue using the c++ program even when the notepad is open? I tried system("filename.txt") But I can't continue using the c++ program unless I close the notepad file. is this possible?

You didn't write on what OS you're on but on windows you can use

system("start notepad.exe");

for example:

#include <iostream>

int main (void){

    system("start notepad.exe");
    std::string x;
    std::cin>>x;
    std::cout<<x;
    return 0;
}

the trick is the "start" command rather then just the filename

另外,您可以像这样使用ShellExecute

ShellExecute(NULL, "open", _T("notepad.exe"), NULL, NULL, SW_SHOWNORMAL);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM