I am trying to create a pointer to one of the main () arguments in my program. I set the start pointer, then I set it to the 2nd element of the array, but I get an error when trying to compile, segmentation error. Is this because the pointer points to a bad address?
Here is the code:
char *filename;
*filename = argv[1];
printf("The filename is: %s", *filename);
I get errors regarding a pointer trying to pass an argument as an int. Is it because the pointer is actually an integer value of the address, and I'm trying to set it equal to a string?
Edit: When I go to "filename = argv [1]", I get the following error from my compiler: assignment discards qualifiers from the target pointer type.
source
share