2

argv

view story
linux-howto

http://www.daniweb.com – Hi guys I use the following code to check if a user has specified a certain argument: if (strcmp(argv[i], "-i") == 0) {         // do something } I use the following code to check whether any arguments have been specified (e.g. -i test1) but it gives me a segemtation fault if no arg for -i is specified: if (strcmp(argv[i], "-i") == 0) {         if(strcmp(argv[i+1], "") == 0) {                 //print error         } } I suspect its the "i+1" bit, as its looking for something thats not there. Can someone please tell me how to fix this. (General)