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 ...
随机推荐
- android 之 TabHost
TabHost的实现有两种方式,第一种继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost.各个Tab中的内容在布局文件中定义就行了. mainAct ...
- [android开发篇]安装android sdk的时候请注意
第二就是: 如果要国内镜像的话: 3.大连东软信息学院镜像服务器地址: http://mirrors.neusoft.edu.cn 端口:80 随便选择一个就行啦.这里我选择的是第三个站点,即大连东 ...
- TOJ 2703: Cow Digit Game
2703: Cow Digit Game Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByte Total Submit ...
- json的两种表示结构(对象和数组).。
JSON有两种表示结构,对象和数组.对象结构以”{”大括号开始,以”}”大括号结束.中间部分由0或多个以”,”分隔的”key(关键字)/value(值)”对构成,关键字和值之间以”:”分隔,语法结构如 ...
- vue 自定义日历组件
<template> <div class=""> <div class="calendarTraffic" name=" ...
- POJ——1364King(差分约束SPFA判负环+前向星)
King Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11946 Accepted: 4365 Description ...
- UOJ 274 【清华集训2016】温暖会指引我们前行 ——Link-Cut Tree
魔法森林高清重置, 只需要维护关于t的最大生成树,然后链上边权求和即可. 直接上LCT 调了将近2h 吃枣药丸 #include <cstdio> #include <cstring ...
- BZOJ 1095 [ZJOI2007]Hide 捉迷藏 ——动态点分治
[题目分析] 这题好基啊. 先把分治树搞出来.然后每个节点两个堆. 第一个堆保存这个块里的所有点(即分治树中的所有儿子)到分治树上的父亲的距离. 第二个堆保存分治树子树中所有儿子第一个堆的最大值. 建 ...
- 算法复习——有源汇上下界可行流(bzoj2396)
题目: Description We are supposed to make a budget proposal for this multi-site competition. The budge ...
- 【BZOJ3611】大工程(虚树,DFS序,树形DP)
题意:有一棵树,树有边权,有若干次询问,给出一些点,求: 1.这些点互相之间的距离之和 2.点对距离中的最大和最小值 n<=1000000 q<=50000并且保证所有k之和<=2* ...