void display(char * str){
printf(\"%s: Missing file\\n\", str);
}
int main(int argc, char **argv)
{
int longIndex, opt = 0;
const char *optString = \"h?
The question mark '?' is returned by getopt when it finds an argument that's not in the optstring or if it detects a missing option argument, so you shouldn't use '?' in optstring because it's sort of reserved for that, instead you should use the more conventional 'h' for help.
See the man page
Edit: This is an example:
switch (opt) {
case 'n':
some_flag = 1;
break;
case 'h': /* help */
default: /* '?' unknown opt or missing arg*/
fprintf(stderr, "Usage: %s [-n nsecs] \n", argv[0]);
exit(EXIT_FAILURE);
}