linux解析命令列引數getopt long

2021-06-26 07:14:58 字數 585 閱讀 9842

直接啟動nginx,其實linux上其實提供了解析命令列引數的函式getopt_long(標頭檔案getopt.h),特別容易使用,這些都是在webbench乙個開源專案中get到的。

#include #include #include int clients=1;

int force=0;

static const struct option long_options=

, ,

, ,

};static void usage()

int main(int argc, char *argv)

}printf(" vaynedu try to use getopt\n");

return 0;

}

輸出結果演示:

具體的使用方法和高階操作,看了兩篇很好的部落格,我也就不多bb了

linux-解析命令列選項getopt_long用法

函式getopt(),及其引數optind

解析命令列引數

include include include include int make argv const char astr,const char delimiters,char argvp void free argv char argvp int main int argc,char argv i...

linux中解析命令列引數

linux 中解析命令列引數 getopt long用法 getopt long支援長選項的命令列解析,使用man getopt long,得到其宣告如下 include int getopt long int argc,char const argv,const char optstring,co...

LINUX中解析命令列引數

author liujun time 2013 3 18 在linux中你輸入比如 insert ll kk mm qq 你如何得到ll kk mm qq,這是需要用到命令列的解析,來分離字串。有三種方法 第一 getopt long支援長選項的命令列解析,使用man getopt long,得到其...