从命令提示符执行 C++ 程序

Execute C++ program from command prompt

我在 Eclipse 中创建了一个程序,它运行的唯一方式是从控制台应用程序,如 Windows 中的命令提示符或 Unix 终端。我正在使用 windows OS 所以我想知道如何从命令提示符和 unix 终端执行程序?

查看 "start" 命令的文档。

C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
  [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
  [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
  [command/program] [parameters]

"title"     Title to display in window title bar.
path        Starting directory.
B           Start application without creating a new window. The
            application has ^C handling ignored. Unless the application
            enables ^C processing, ^Break is the only way to interrupt
            the application.

在 Unix 上 g++ <file-path> 示例(来自主目录)g++ ././C++/E1-13.c To 运行 it ././C++/a.out 示例(目录内)g++ E1-13.c To 运行 it ./a.out

注意:您可以使用其他文件扩展名,例如 .cc、.cpp 等