hello.c
#include <stdio.h>int main(int argv,char* argc[]){ printf("hello word!\n"); return 0;}
编译后 直接运行 && 作用为连接命令
gcc hello.c -o main.out && ./main.out
再运行 就查看返回参数
echo $?
argv作用:
main.c文件代码
#include <stdio.h>int main(int argv,char* argc[]){ printf("argv is %d\n",argv); return 0;}
先把文件编译 然后运行
[[email protected] les3]# gcc main.c -o m2.out[[email protected] les3]# lsm2.out main.c main.out[[email protected] les3]# ./m2.out -l -aargv is 3[[email protected] les3]# ./m2.out -largv is 2
argc
main.c代码:
#include <stdio.h>int main(int argv,argv); int i; for(i=0;i<argv;i++) { printf("argc[%d] is %s\n",i,argc[i]); } return 0;}
编译后运行 并加上参数
[@L_502_4@ les3]# gcc main.c -o m3.out[[email protected] les3]# lsm2.out m3.out main.c main.out[[email protected] les3]# ./m3.out -l -a asdfasf fdsafargv is 5argc[0] is ./m3.outargc[1] is -largc[2] is -aargc[3] is asdfasfargc[4] is fdsaf总结
以上是内存溢出为你收集整理的linux c 的main 函数中的return 和 查看返回参数 argv 与 argc 作用全部内容,希望文章能够帮你解决linux c 的main 函数中的return 和 查看返回参数 argv 与 argc 作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)