加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

Linux 应用——常用函数(usual function)

发布时间:2020-12-14 02:05:32 所属栏目:Linux 来源:网络整理
导读:main 函数: 新建 testmain.c #include sys/types.h #include sys/stat.h #include fcntl.h #include stdio.h int main(int argc,char **argv) { int i,j; i = atoi(argv[1]); j = atoi(argv[2]); printf("the program name is %s",argv[0]); printf("the c

main函数:

新建testmain.c

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

int main(int argc,char **argv)

{

int i,j;

i = atoi(argv[1]);

j = atoi(argv[2]);

printf("the program name is %s",argv[0]);

printf("the command line has %d argument:n",argc);

printf("%d,%dn",i,j);

?

return 0;

}

参数argcmain函数中所带的参数个数, argv[0]为参数名称,courier;">argv[1]argv[2]……才是真正的参数

编译生成testmain可执行文件

运行:

  the program name is ./mnt/usb/testmain  这是因为运行的程序就是?./mnt/usb/testmain?

  the command line has 3 argument  (输入两个参数,加上?argv[0]?刚好3个)

  10,11  (输入的2个参数)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读