/ Published in: C

This is a simple bit of code to show how you can use the "getopt()" function to parse input arguments without headaches.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
void print_help() { } char* input_file = NULL ; char *query=NULL; char opt_char=0; while ((opt_char = getopt(argc, argv, "i:q:vh")) != -1) { switch(opt_char) { case 'h': print_help(); break; case 'v': print_version() ; break ; case 'i': input_file= optarg ; break ; case 'q': query= optarg ; break ; default: print_help(); break; } }
URL: http://snippets.dzone.com/posts/show/6850
Comments
