How do I run C++ program in Powershell, just like CMD?

混江龙づ霸主 提交于 2020-08-25 08:51:41

问题


Like in CMD, to run a C++ program, I use the command g++ filename.cpp, then I run it using the command a.exe, which opens the output in the CMD itself. How to do such thing using a PowerShell? I am unable to open the file by simple command as a.exe. Am I doing it the wrong way?


回答1:


It is a best practice to use the invocation operator and to quote the command.

& ".\a.exe" p1 p2 p3

PowerShell will also allow the use of / as the path separator.

& "./a.exe" p1 p2 p3 "p4 with space"



回答2:


by running g++ filename.cpp on PowerShell it generates a.exe file by default on running a.exe it gives an error

so follow these commands

g++ filename.cpp -o filename.exe

filename.exe



来源:https://stackoverflow.com/questions/45293279/how-do-i-run-c-program-in-powershell-just-like-cmd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!