linux getopt函数详解
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char **argv)
{
char ch;
//opterr = 0; //getopt出错不向stderr输出错误信息 while((ch = getopt(argc, argv, "ab:c::")) != -)
{
switch(ch)
{
case 'a':
printf("option = a, optopt = %c, optind = %d, optarg = %s\n",
optopt, optind, optarg);
break;
case 'b':
printf("option = b, optopt = %c, optind = %d, optarg = %s\n",
optopt, optind, optarg);
break;
case 'c':
printf("option = c, optopt = %c, optind = %d, optarg = %s\n",
optopt, optind, optarg);
break;
case 'd':
printf("option = d, optopt = %c, optind = %d, optarg = %s\n",
optopt, optind, optarg);
break;
default:
printf("option = %c\n", ch);
}
printf("argv[%d] = %s\n", optind, argv[optind]);
} printf("ch == -1, optind = %d", optind); return ;
}
linux getopt函数详解的更多相关文章
- linux select函数详解
linux select函数详解 在Linux中,我们可以使用select函数实现I/O端口的复用,传递给 select函数的参数会告诉内核: •我们所关心的文件描述符 •对每个描述符,我们所关心的状 ...
- linux select函数详解【转】
转自:http://www.cnblogs.com/ccsccs/articles/4224253.html 在Linux中,我们可以使用select函数实现I/O端口的复用,传递给 select函数 ...
- Linux fcntl函数详解
功能描述:根据文件描述词来操作文件的特性. 文件控制函数 fcntl -- file control 头文件: #include <unistd.h> #include ...
- Linux system函数详解
system 功能:system()函数调用"/bin/sh -c command"执行特定的命令,阻塞当前进程直到command命令执行完毕 原型 int system(cons ...
- Linux wait函数详解
wait和waitpid出现的原因 SIGCHLD --当子进程退出的时候,内核会向父进程SIGCHLD信号,子进程的退出是个异步事件(子进程可以在父进程运行的任何时刻终止) --子进程退出时,内核将 ...
- linux system()函数详解
system(3) - Linux man page Name system - execute a shell command Synopsis #include <stdlib.h> ...
- Linux C popen()函数详解
表头文件 #include<stdio.h> 定义函数 FILE * popen( const char * command,const char * type); 函数说明 popen( ...
- linux内核中send与recv函数详解
Linux send与recv函数详解 1.简介 #include <sys/socket.h> ssize_t recv(int sockfd, void *buff, size_t n ...
- Linux环境fork()函数详解
Linux环境fork()函数详解 引言 先来看一段代码吧, 1 #include <sys/types.h> 2 #include <unistd.h> 3 #include ...
随机推荐
- Python3常用模块的安装
1.mysql驱动:mysql-connector-python 1.安装 $ pip3 install mysql-connector-python --allow-external mysql-c ...
- [android 代码search地址]
http://www.androidcodesearch.com/source/packages/apps/Settings/src/com/android/settings/SecuritySett ...
- 自动化运维之shell通配符,转义符,和元字符(二)
1 shell通配符 通配符看起来有点象正则表达式语句,但是它与正则表达式不同的,不能相互混淆.把通配符理解为shell特殊代号字符就可. 二.shell元字符 shell除了有通配符之外,由shel ...
- 【Luogu】P2953牛的数字游戏(博弈论)
题目链接 自己乱搞……然后一遍AC啦! 思路从基本的必胜态和必败态开始分析.我们把减去最大数得到的数叫作Max,减去最小数得到的数叫作Min. 那么开始分析. 一.0是必败态. 这个没法解释.题目就这 ...
- 干货 | Elasticsearch Nested类型深入详解
在Elasticsearch实战场景中,我们或多或少会遇到嵌套文档的组合形式,反映在ES中称为父子文档. 父子文档的实现,至少包含以下两种方式: 1)父子文档 父子文档在5.X版本中通过parent- ...
- html-Span 指定宽度
html-Span 指定宽度 css: span{ display:-moz-inline-box; display:inline-block; width:150px; } 链接:如何设置HTML ...
- angular中ng-class的一些用法
在前面Angularjs开发一些经验总结中我们说到在angular开发中angular controller never 包含DOM元素(html/css),在controller需要一个简单的POJ ...
- asp.net MVC最简单的增删查改!(详)
折腾了两天搞出来,但原理性的东西还不是很懂,废话不多说上图上代码 然后右键models,新建一个数据模型 注意我添加命名为lianxi 添加后如上 接下来在controllers添加控制器还有在Vie ...
- Lighttpd 服务器的安装
https://www.cnblogs.com/rongfengliang/articles/3503228.html
- BZOJ——1606: [Usaco2008 Dec]Hay For Sale 购买干草
http://www.lydsy.com/JudgeOnline/problem.php?id=1606 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1 ...