My code:
Code:
for(int i=1; i<argc; i++)
{
if( (strcmp(argv[i], "--help"))==0 )
printHelp();
if(argv[i][0] == '-')
{
for(int b=1; b<strlen(argv[i]); b++)
{
if(argv[i][b] == 'd')
key_d=1;
else if(argv[i][b] == 'c')
key_c=1;
else if(argv[i][b] == 'm')
key_m=1;
else if(argv[i][b] == 't')
key_t=1;
else if(argv[i][b] == 's')
key_s=1;
else if(argv[i][b] == 'h')
printHelp();
else
{
printf("%c: invalid key. Use-h or --help to get help", argv[i][b]);
_exit(0);
}
}
}
I enter test -r but I do not see the help that should be output, in the printHelp method I have the help text written about the program!
The text should be displayed after the else but it is not output! Maybe I do not know something yet?