argopt.c
来自「在beginning linux programming 书中提供的第四章的有关」· C语言 代码 · 共 30 行
C
30 行
#include <stdio.h>#include <unistd.h>int main(int argc, char *argv[]){ int opt; while((opt = getopt(argc, argv, "if:lr")) != -1) { switch(opt) { case 'i': case 'l': case 'r': printf("option: %c\n", opt); break; case 'f': printf("filename: %s\n", optarg); break; case ':': printf("option needs a value\n"); break; case '?': printf("unknown option: %c\n", optopt); break; } } for(; optind < argc; optind++) printf("argument: %s\n", argv[optind]); exit(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?