Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用termux 应用程序来编译我的 c/c++代码。g++ [file.cpp] -o [file] and then ./[file]每次在手机上打字 对我来说都很难。谁能告诉我使用一个简单的命令/单词/关键字(类似于“别名”)运行来编译和执行文件的 Linux 脚本?
g++ [file.cpp] -o [file] and then ./[file]
如果您特别想要一个 bash 脚本,请尝试
g++ $1.cpp -o $1 ./$1
将此保存为您喜欢的任何文件名,例如run. chmod +x run然后通过在终端中键入使其可执行。
run
chmod +x run
现在假设您有一个 test.cpp,其内容如下
#include <iostream> int main() { std::cout << "Testing..."; return 0; }
您可以简单地输入./run test您的终端,结果应该是
./run test
Testing...