问题
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