1、源码
#include "stdio.h"
int main(int argc, char **argv)
{
for (size_t i = 0; i < argc; i++)
{
printf("argv[%d] == [%s]\n", i, argv[i]);
}
return 0;
}
2、程序运行:.\main
PS C:\Users\lenovo\Desktop\C_Test> .\main
argv[0] == [C:\Users\lenovo\Desktop\C_Test\main.exe]
3、程序运行传参形式1:.\main hello world!
PS C:\Users\lenovo\Desktop\C_Test> .\main hello world!
argv[0] == [C:\Users\lenovo\Desktop\C_Test\main.exe]
argv[1] == [hello]
argv[2] == [world!]
4、程序运行传参形式1:.\main “hello world!” “keep going!”
PS C:\Users\lenovo\Desktop\C_Test> .\main "hello world!" "keep going!"
argv[0] == [C:\Users\lenovo\Desktop\C_Test\main.exe]
argv[1] == [hello world!]
argv[2] == [keep going!]
|