像CMD一样,如何在Powershell中运行C ++程序? [英] How do I run C++ program in Powershell, just like CMD?

查看:817
本文介绍了像CMD一样,如何在Powershell中运行C ++程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与CMD类似,要运行C ++程序,我使用命令 g ++ filename.cpp ,然后使用命令 a运行它。 exe ,它将在CMD本身中打开输出。如何使用PowerShell执行此操作?我无法通过简单命令 a.exe 打开文件。我是用错误的方式吗?

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?

推荐答案

使用调用运算符并引用命令是一种最佳实践。 / p>

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

& ".\a.exe" p1 p2 p3

PowerShell还将允许使用 / 作为路径分隔符。

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

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

这篇关于像CMD一样,如何在Powershell中运行C ++程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆