How to handle exceptions when we give no argument to a C executable program [duplicate]
问题 This question already has answers here : getopt fails to detect missing argument for option (5 answers) Closed 6 years ago . I have this C program in which it should be given arguments like the following: ./program -i inputFile -o outputFile and here's my related section of code while ((c = getopt(argc, argv, "i:o:")) != -1) { switch (c) { case 'i': inFile = strdup(optarg); break; case 'o': outFile = strdup(optarg); break; default: error_usage(argv[0]); } } also here's the error_usage