运行 预编译的 C 程序

Run precompiled C program

我目前正在开发一个加密文本文件的程序。我用 C 语言在 Turbo C++ 中实现了它,但我的主要问题是:

我需要 运行 turboc++,以便我的 .exe 程序能够 运行。这里有人知道编译它并将其 运行 作为独立程序的方法吗?

TurboC++ 是一个 过时的 编译器,用于 C++ 或 C 的过时变体。使用最新的编译器(例如 GCC 8 or Clang 7; both are open source 对于最近的 C11 或 C++14(或 C++11)标准,可以免费使用)。 摆脱 TurboC++,因为它过时(与其他现有编译器相比,它不是一个好的编译器)。

如果使用 GCC,您将编译 C 文件 foo.c using gcc -Wall -g -O foo.c -o foo. If using Clang, you'll compile with clang -Wall -g -O foo.c -o foo. Don't forget to enable all warnings and debug info. You'll get an executable foo which can be run without having the source code. That executable is specific to your operating system and to your instruction set architecture

I need to run turboc++, in order for my .exe program to run.

使用任何足够好的 C 或 C++ 编译器,您不需要编译器 运行 它正在生成的可执行文件。

不要混淆 compiler with the IDE or source code editor you'll use to write C or C++ source code. All C or C++ compilers I heard of are command line programs, that might be run from a terminal, an IDE, a good source code editor (such as emacs or vim).

如果您的源代码是 C++,即 bar.cc,请使用 g++ -Wall -g -O bar.cc -o barclang++ -Wall -g -O bar.cc -o bar

使这些编译命令(我为 Linux 提供)适应您的操作系统。在 Windows 上,可执行文件的文件路径以 .exe.

结尾

当然,GCC和Clang都可以编译link a program made of several translation units. Learn to use some build automation tool, such as make or ninja。这些工具正在驱动编译和链接命令。

如果您正在学习用 C++ 编程,请注意它是一种非常困难的编程语言(您需要多年的努力才能掌握它)。请注意,Linux 是一个对开发人员非常友好的 operating system, mostly made of free software,您可以研究其源代码。这就是为什么我向那些学习 C++ 或 C 的人推荐 Linux。

PS。如果你的老师需要TurboC,我建议和他有礼貌地讨论,建议你用GCC或Clang做作业。