简体   繁体   English

运行C ++程序和记事本

[英]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? 如何在C ++中打开记事本,然后即使打开记事本仍继续使用c ++程序? I tried system("filename.txt") But I can't continue using the c++ program unless I close the notepad file. 我尝试使用system(“ filename.txt”),但除非关闭记事本文件,否则无法继续使用c ++程序。 is this possible? 这可能吗?

You didn't write on what OS you're on but on windows you can use 您没有在所用的操作系统上写东西,但可以在Windows上使用

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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