Command Line agruments
Hello,
I'm trying to familiarize myself with argc, and argv, but I am misisng someting and any help would be appericated.
My code is as follows:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
if (*argv[1] == 'h')
{
printf("help\n");
}
return 0;
}
WHen I run the program, it seg faults, but if I run it with the command line agrument h, it prints the message. So what I want to do is:
./1
return nothing
./1 h
print help
Any help would be great.
Lazyuser
|