[C/C++] Using `getopt' in c/c++
2012-06-08 14:00
288 查看
Using `getopt' in c/c++
Could not get the real original version for the examples, list one of them first, usefully and well tested.
The GNU C Library - http://www.gnu.org/software/libc/manual/html_node/index.html#Top
Could not get the real original version for the examples, list one of them first, usefully and well tested.
Examples
Example 1
// getopt_example.cpp #include <unistd.h> int main(int argc, char *argv[]) { int option = -1; char *addr, *port; while ((option = getopt (argc, argv, "i:p:")) != -1) { switch (option) { case 'i': addr = strdup(optarg); break; case 'p': port = strdup(optarg); break; default: /* unrecognised option ... add your error condition */ break; } } /* rest of program */ return 0; }
See Also
Getopt - The GNU C Library - http://www.gnu.org/software/libc/manual/html_node/Getopt.htmlThe GNU C Library - http://www.gnu.org/software/libc/manual/html_node/index.html#Top
相关文章推荐
- kingofark's Ineffective C/C++:自白1:返回值的运用
- 解决“OperationalError: (1862, 'Your password has expired. To log in you must change it using ...”
- kingofark's Ineffective C/C++:低手自序
- kingofark's Ineffective C/C++:低手自序
- kingofark's Ineffective C/C++:自白2:有符号、无符号还有位运算,我的天!
- kingofark's Ineffective C/C++:自白1:返回值的运用
- kingofark's Ineffective C/C++:低手自序
- kingofark's Ineffective C/C++:低手自序
- kingofark's Ineffective C/C++:自白1:返回值的运用
- kingofark's Ineffective C/C++:低手自序
- kingofark's Ineffective C/C++:自白2:有符号、无符号还有位运算,我的天!
- kingofark's Ineffective C/C++:自白1:返回值的运用
- kingofark's Ineffective C/C++:低手自序
- Building a project using a generated make file results in error 'make: 1254-055 Dependency line need
- kingofark's Ineffective C/C++:自白2:有符号、无符号还有位运算,我的天!
- kingofark's Ineffective C/C++:自白2:有符号、无符号还有位运算,我的天!
- torch7-- errors using gfx in the tutorial--Cannot find module 'pty.js'--[gfx.js] rendering cell
- why it doesn't popup multi definitions error for method in .h class for C++?
- kingofark's Ineffective C/C++:自白1:返回值的运用
- QtCreator编译报错 redeclaration of C++ built-in type 'wchar_t'