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.
一段非常简单的 C++ 代码,如下所示:
int main(int argc, char **argv){ std::cout << "argc: " << argc << std::endl; }
编译g++ -o hello hello.cpp
g++ -o hello hello.cpp
./hello u
argc: 2
./hello u +
argc: 3
./hello u *
argc: 26
26
壳膨胀。*由 shell 扩展为当前目录中的所有文件,其中似乎有 24 个,并将它们作为单独的参数传递给您的程序。
*
由于这看起来像是来自 UNIX shell 的调用,因此请使用
./hello u \*
或者
./hello u '*'
您需要将 shell 解释为特殊字符的内容传递给' '.
' '
所以正确的命令行调用应该是./hello u '*'