当我们定义 main
函数体的参数时,为什么不能将其定义为整数数组或者可以?
如果可以,我如何将其中的整数值分配给变量。
最佳答案
关于main
的标准:
N4140, § 3.6.1 [basic.start.main]/2
It shall have a declared return type of type
int
, but otherwise its type is implementation-defined.
因此一个实现可以提供int main(int argc, int argv[])
。但我不知道这样做,所以你必须自己写。将字符串转换为整数要容易得多。
关于c++ - 使 argv 成为整数数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40099023/