国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

函數(shù)getopt()及其他參數(shù)

2019-11-11 07:16:12
字體:
來源:轉載
供稿:網(wǎng)友

getopt():用來解析命令行參數(shù)

#include<unistd.h> extern char * optarg; extern int optind; extern int opterro; extern int optopt;

getopt(int argc, char ** argv, char *options) 按照字符串options提供的選項在參數(shù)列表argv中解析出選項。 注:選項和參數(shù) 1. 單一字符是選項 2. 字符后面加:表示選項后需要加一個參數(shù)(隔一個空格或直接跟在后面) 3. 字符后面加兩個::,表示緊接著需要一個參數(shù)

eg:

getopt(argc, argv, "ab:c:de::")執(zhí)行:./main file1 -a -b -c code -d file2 -e file3結果:option : a optarg : (null) opterror : 1 optind : 3option : b optarg : -c opterror : 1 optind : 5option : d optarg : (null) opterror : 1 optind : 7option : e optarg : (null) opterror : 1 optind : 9argv變成:./main -a -b -c -d -e file1 code file2 file3
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 磐石市| 钦州市| 屯昌县| 保亭| 台山市| 贺州市| 理塘县| 武义县| 庄浪县| 饶阳县| 上饶县| 太湖县| 大邑县| 丽江市| 杭锦后旗| 荣成市| 博罗县| 齐齐哈尔市| 万载县| 呼图壁县| 勃利县| 潞城市| 宜宾市| 萨嘎县| 合作市| 本溪| 荥阳市| 右玉县| 永定县| 武城县| 南充市| 孟州市| 和平县| 房产| 深水埗区| 灵宝市| 保康县| 班玛县| 饶河县| 崇左市| 桑日县|