首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > getopt()用法
【标  题】:getopt()用法
【关键字】:getopt
【来  源】:http://blog.chinaunix.net/article.php?articleId=59053&blogId=5421

getopt()用法

getopt()用法

#include<stdio.h>
#include<unistd.h>

extern char *optarg;
extern int optind, optopt,opterr;

int main(int argc,char **argv)
{
        int ch;

        while((ch = getopt(argc,argv,"a:bcd")) != -1)
        switch(ch)
        {
        case 'a':
                printf("option a:'%s' ",optarg);
                break;
        case 'b':
                printf("option b :b ");
                break;
        case '?':
        case 'h':
                printf("usage ");
                break;
        default:
                printf("other option :%c ",ch);
        }
        if (1 == argc)
                printf("usage ");
        printf("optopt +%c ",optopt);
}

郎咸平10月1日在墨尔本的演讲(摘选):【上一篇】
手把手升级vi:【下一篇】
【相关文章】
  • [Perl]实用性很强的模块Getopt::Std和Getopt::Long
  • 向脚本传递参数-getopts
  • getopts使用样例
  • getopts的学习笔记
  • 用getopt()处理命令行多参数
  • 一个使用getopt()函数获取命令行参数的例子
  • 【随机文章】
  • 管理打印作业
  • 解决fortune有颜色字符的问题
  • 《java与模式》笔记(八) 简单工厂模式
  • SCO一个网卡上面绑定多个IP地址
  • WSDL在Web Service中的意义和作用
  • Solaris9 x86下如何挂载和永久挂载windows fat32分区
  • COM程序编写入门(二)
  • Personal Fedora Core 4 Installation Guide
  • 系统启动脚本分析
  • lsof常用技巧
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.