Home Page
Search
\begin{md} # 函数最大参数个数 测试一个 C 函数最多能有多少个参数 python 脚本生成包含任意个参数的 C 语言函数: ``` python def fun(): n = input("// enter function argument count:\n") n = int(n) s = "#include
\n\nvoid print(" for i in range(n): s += "int a" + str(i) + "," s += "int a" + str(i+1) + ")" s += "{\n" for i in range(n+1): s += '\tprintf("%d\\n", a' + str(i) + ');\n' s += "}" s += "\n\n" s += "int main() {\n" s += "\tprint(" for i in range(n): s += str(i+2) + "," s += str(n+3) s += ");\n" s += "\treturn 0;\n" s += "}" print(s) fun() ``` 编译执行命令: ``` bash python3 main.py |tee test.c && gcc test.c && ./a.out ``` gcc 9.3 下10万个参数是可以编译执行的。参数数量应该和栈大小有关。 \end{md}
Home Page