When using ‘int main(int argc, char* argv[])’,
I am curious why it says that no options were entered
as shown in the picture below even though no value was entered with the keyboard
in the console window when compiling.
My code is
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
if (argc == 1) {
fputs("error! You did not enter any options....n", stderr);
exit(1);
}
printf("You entered %d options.nn", argc - 1);
for (int i = 1; i < argc; i++)
printf("argv[%d] = %sn", i, argv[i]);
return 0;
}
enter image description here
As soon as I press ctrl + F5, a result screen like that appears.
New contributor
user25111672 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.