I know that you will rap me over the knuckles but.
Why does it make Segmentation fault
char* cmd;
strcpy(cmd, argv[0]);
when this d
You get a seg. fault because cmd
in your first example isn't pointing to anything (or, rather, it's pointing to something that's undefined - so attempting to read characters from or write characters to the pointer will probably result in an access violation).
In the second example, you're setting cmd to point to a legitimate string of chars.