I found two ways of passing command-line arguments into a character array:
int main (int argc, char **argv)
{
const char *s1 = argv[0];
char s2[256];
strcpy(s2, argv[0]);
printf("s1: %s\ns2: %s\n\n", s1, s2);
}
Compiled with the IBM xlc compiler on an AIX system Returns
[MyPrompt]> ./a.out
s1: ./a.out
s2: ./a.out
Which implementation (s1 or s2) is correct? s1 is nice because argv[0] can be any length. s2 requires that the length of argv[0] < 256 characters.
I do not understand how/why s1 should work. I think the right-hand side of s1 should be required at compile time, but I think it's generated at run-time.