main( int argc ,char*argv[ ] ) {int n,i=0 ; while(argv[ 1 ][ i ='\0' ) {n=fun();i++;}main( int argc ,char*argv[ ] ){int n,i=0 ;while(argv[ 1 ][ i ='\0' ){n=fun();i++;}printf(%d\n",n*arge);}int fun(){static int s=0;s+=1;return s;}假设程序经编译

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 08:15:03
main( int argc ,char*argv[ ] ) {int n,i=0 ; while(argv[ 1 ][ i ='\0' ) {n=fun();i++;}main( int argc ,char*argv[ ] ){int n,i=0 ;while(argv[ 1 ][ i ='\0' ){n=fun();i++;}printf(%d\n
xJ@_P[;M IRD{QPPEEi+jqFd&-Ooʛq(œf89ST1&& X 52,?xԔ8Q>yOF2)W?d~|M,ȏIC\ 1lUQ*ɦ^71Xrlw&q[ n;Lb%]>v߻ EtsBML(9046`Iˡl޵ͥ%vxCm^)x;

main( int argc ,char*argv[ ] ) {int n,i=0 ; while(argv[ 1 ][ i ='\0' ) {n=fun();i++;}main( int argc ,char*argv[ ] ){int n,i=0 ;while(argv[ 1 ][ i ='\0' ){n=fun();i++;}printf(%d\n",n*arge);}int fun(){static int s=0;s+=1;return s;}假设程序经编译
main( int argc ,char*argv[ ] ) {int n,i=0 ; while(argv[ 1 ][ i ='\0' ) {n=fun();i++;}
main( int argc ,char*argv[ ] )
{int n,i=0 ;
while(argv[ 1 ][ i ='\0' )
{n=fun();i++;}
printf(%d\n",n*arge);
}
int fun()
{static int s=0;
s+=1;
return s;
}假设程序经编译连接生成可执行文件exam.exe,若输入exam 123 ,结果为6,为什么?

main( int argc ,char*argv[ ] ) {int n,i=0 ; while(argv[ 1 ][ i ='\0' ) {n=fun();i++;}main( int argc ,char*argv[ ] ){int n,i=0 ;while(argv[ 1 ][ i ='\0' ){n=fun();i++;}printf(%d\n",n*arge);}int fun(){static int s=0;s+=1;return s;}假设程序经编译
printf(%d\n",n*arge);中的arge是argc吗?
如果是的话,结果应该是6,输入exam 123后,参数argc = 2,argv[1] = "123".
因为字符串“123”长度为3,所以argc * n 等于2 * 3 等于6.若exam后没有参数,则argc = 1,
argv[0] = main;