b********e 发帖数: 693 | 1 Which one of the following function declarations do you use for a function
that takes a variable number of parameters and uses all of them?
A. void function (first, others[]);
B. void function(argc, *argv[]);
C. void function(...);
D. void function(int first, ...);
E. void[] function(); |
M********5 发帖数: 715 | |
t******e 发帖数: 1293 | 3 D使用的是C里面的变长参数,肯定可以
B类似main函数,貌似也没有问题
【在 b********e 的大作中提到】 : Which one of the following function declarations do you use for a function : that takes a variable number of parameters and uses all of them? : A. void function (first, others[]); : B. void function(argc, *argv[]); : C. void function(...); : D. void function(int first, ...); : E. void[] function();
|
M********5 发帖数: 715 | 4 You have reminded me of the point.
I think the answer might be D. The reason is that B is used to accept inputs
from the command line. But to provide a variable length of parameters
inside a function, the choice might be D.
【在 t******e 的大作中提到】 : D使用的是C里面的变长参数,肯定可以 : B类似main函数,貌似也没有问题
|
t******e 发帖数: 1293 | 5 B也不一定是command line的参数,你也可以自己用一个指向数组的指针
来表示变长参数
inputs
【在 M********5 的大作中提到】 : You have reminded me of the point. : I think the answer might be D. The reason is that B is used to accept inputs : from the command line. But to provide a variable length of parameters : inside a function, the choice might be D.
|
f*****y 发帖数: 444 | 6 D. B is incorrect because it need type such as ...int argc, char* argv[]
but I don't know why it ask "use all of them" |
h*********6 发帖数: 19 | 7 agree
【在 f*****y 的大作中提到】 : D. B is incorrect because it need type such as ...int argc, char* argv[] : but I don't know why it ask "use all of them"
|
d**e 发帖数: 6098 | 8 如果不是类型的问题,B正确吗?
还是这种形式是专门给main用的?
【在 f*****y 的大作中提到】 : D. B is incorrect because it need type such as ...int argc, char* argv[] : but I don't know why it ask "use all of them"
|
i*****e 发帖数: 113 | 9 B是编译器将一堆可变参数,压到栈里面,然后给你指针的
【在 d**e 的大作中提到】 : 如果不是类型的问题,B正确吗? : 还是这种形式是专门给main用的?
|