我很难把字符串'*'变成argv。

时间:2021-08-24 22:23:25

I would like to pass something like this: 6 3 * into argv so that

我想要传递这样的信息:6 3 *进入argv。

*argv[1] = '6'
*argv[2] = '3'
*argv[3] = '*'

but what ends up happening is the asterisk causes a bunch of related file names to be passed to argv, and I cant find any info on why this is...

但是最终的结果是星号会导致一些相关的文件名被传递给argv,我找不到任何关于这个的信息。

2 个解决方案

#1


2  

Use \ to escape the * character when you call the program:

当你调用程序时,使用\来逃避*字符:

./tst 6 3 \*

#2


1  

That's a problem between you and your shell, nothing to do with C. Launch your program like this:

这是你和你的shell之间的问题,与c无关。启动你的程序:

./a.out 666 3333 "*"

#1


2  

Use \ to escape the * character when you call the program:

当你调用程序时,使用\来逃避*字符:

./tst 6 3 \*

#2


1  

That's a problem between you and your shell, nothing to do with C. Launch your program like this:

这是你和你的shell之间的问题,与c无关。启动你的程序:

./a.out 666 3333 "*"