getopt实例
来源:互联网 发布:药品数据 编辑:程序博客网 时间:2024/06/03 15:52
#include <stdio.h>
#include <getopt.h>
int main(int argc, const char **argv)
{
int c;
while (1)
{
int option_index = 0;
struct option long_options[] = {
{ "type", 1, 0, 't' },
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0 }};//END
c = getopt_long(argc, (char **)argv, "t:h", long_options, &option_index);
if (c == -1)
break;
char * opt_args = NULL;
switch (c)
{
case 't':
{
opt_args = optarg;
if(opt_args)
{
printf("t:%s\r\n", opt_args);
}
break;
}
case 'h':
{
printf("help\r\n");
break;
}
default:
{
printf("unknow!\r\n");
break;
}
}
}
return 0;
}
#include <getopt.h>
int main(int argc, const char **argv)
{
int c;
while (1)
{
int option_index = 0;
struct option long_options[] = {
{ "type", 1, 0, 't' },
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0 }};//END
c = getopt_long(argc, (char **)argv, "t:h", long_options, &option_index);
if (c == -1)
break;
char * opt_args = NULL;
switch (c)
{
case 't':
{
opt_args = optarg;
if(opt_args)
{
printf("t:%s\r\n", opt_args);
}
break;
}
case 'h':
{
printf("help\r\n");
break;
}
default:
{
printf("unknow!\r\n");
break;
}
}
}
return 0;
}
- getopt实例
- Getopt::Std模块简单实例
- getopt、getopt_long、getopt_long_only使用实例
- getopt
- getopt
- getopt
- getopt
- getopt
- getopt
- getopt ()
- getopt
- getopt
- getopt
- getopt
- getopt
- getopt
- getopt()
- getopt
- android weiget 实时数据更新
- Share Your Knowledge and Experiences
- php常用函数
- UVa 167 - The Sultan's Successors
- IOS单例模式及单例模式的优缺点
- getopt实例
- js学习
- ActiveSync失败和RTC的关系
- 常规递归和尾递归的性能比较
- 使用OpenCV实现内存中图像数据的RGB-->HSV转换
- XPath 对xml文件操作
- 启动loadrunner的agent时,发现日志中报端口已被占用,启动失败解决办法
- Pattern Pathology
- Beginning Python - Chapter6 : More Abstraction