Here is my program.
#include <stdio.h>
void help(const char *argv);
int main(int argc, const char *argv[]) {
const char *p;
int x;
for(x = 0; x < argc; x++) {
p = argv[x];
if(*p == '-') {
p++;
}
switch(*p) {
case 'h':
help(*argv);
return 0;
break;
}
}
return 0;
}
void help(const char *argv) {
fprintf(stderr, "Usage %s: [option]\n", argv[0]);
}
The problem is that during compile process I get
warning: format ‘%s’ expects type ‘char *’, but argument 3 has type
‘int’
How to print program name in help function ?
That should be
and
Using a
char**because you are passing an array of strings (aka pointers to char).