一个非常简单的C++代码,如下所示:
int main(int argc, char **argv){
std::cout << "argc: " << argc << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
编译 g++ -o hello hello.cpp
./hello u,输出是argc: 2;./hello u +,输出是argc: 3;./hello u *,输出是argc: 26,为什么26?Win*_*ute 10
壳牌扩张.*由shell扩展到当前目录中的所有文件,其中似乎有24个,并将它们作为单独的参数传递给您的程序.
由于这看起来像来自UNIX shell的调用,请使用
./hello u \*
Run Code Online (Sandbox Code Playgroud)
要么
./hello u '*'
Run Code Online (Sandbox Code Playgroud)