main

1.

#include<stdio.h>
#include<stdlib.h>
int sum(int N,int arr[]);
int main(int argc,char **argv)
{
int result;
int b[argc];
printf("%d\n",argc-1);
for (int i=0;i<argc;i++)
{
b[i]=atoi(argv[i]);
result=sum(argc,b[i]);
}
printf("the result is %d\n",result);
return 0;
}
int sum(int N,int arr[]){
        int s=0;
        for(int i=0;i<N;i++)
                s+=arr[i];
return s;
}
上一篇:漫话Redis源码之十八


下一篇:int main( int argc, char* argv[] ) 中arg和argv参数的解析及示例