int main()
takes 1 command line argument: in_filename = argv[1]
(command line argument example: inputfile.txt
). *in_filename
and *out_filename
are both const char *. I want to write at out_filename address the value stored in the address pointed by *in_filename. For example if *in_filname is 0x7fffffffe930
"inputfile.txt" at *out_filename pointed address (different from 0x7fffffffe930
) will be stored "inputfile.txt".
int main(int argc, char **argv){
const char *in_filename, *out_filename;
in_filename = argv[1];
out_filename = argv[1];
return 0
}
If I use the code above out_filename will have the same address as in_filename but I want him to have a different address and the same value (inputfile.txt) as the one stored at the address pointed by in_filename.
If I use
int main(int argc, char **argv){
const char *in_filename, *out_filename;
in_filename = argv[1];
strcpy(out_filename, in_filename);
return 0
}
I receive in Debugger I receive the error: out_filename has an address 0x40000 but there is an error accessing it and the program stops. in_filename has a adress and the correct value stored at it. What is the right code for this task?