c语言中的定义。
头文件:#include<unistd.h>
函数定义:int getopt(int argc,char * const argv[ ],const char * optstring);
extern char *optarg;
extern int optind, opterr, optopt;
说明:
:
b:c:)
getopt函数所设置的全局变量如下:
optarg : 指向当前选项参数(如果有)的指针
optopt : 最后一个已知选项。
下。
语言实现短命令
代码如下:
View Code
/*File: getoptShort.cAuthor : MikeE-Mail : Mike_Zhang@live.com */#include <stdio.h>#include <unistd.h>#include <string.h>extern char *optarg;extern int opterr;int main(int argc,char **argv){int c,index;;int port = 8000;opterr = 0;)) != -1){switch(c){:strcpy(host,optarg);break;:port = atoi(optarg);break;:printf();return 1;default:break;}}printf( ,host,port);for(index = optind;index < argc;index++)printf(,argv[index]);return 0;},香港空间,虚拟主机,香港服务器充满了恐惧的声音,一种不确定的归宿的流动。