Emmanuel Delahaye wrote:
vinayby a écrit :
<snip>
2) I was wondering if it was possible to change argv[0] during
runtime...
Yes, it is.
Just be careful what your are doing. argv points to an array of pointers
to char. You can decide to make argv[0] point elsewhere:
argv[0] = "My smart name";
but don't use strcpy(),
strcpy(argv[0], "My smart name"); /* WRONG! */
because you know nothing about the space pointetd by argv[0].
This is wrong. One may change argv as it is not const-qualified
and one may change the strings pointed to by argv[i], i < argc,
because the standard allows it. So, snprintf() or strncpy()
restricted by the original length of the string pointed to by
argv[0] is the right answer.
See the thread starting at
<11**********************@g49g2000cwa.googlegroups .com>
for a detailled discussion.
he process table show the newname rather than say "a.out"
OR is it OSdependent
This is not necessarily possible. argv[0] may point to a copy
of the name at the start of the program.
So, OS dependent means are probably necessary.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.