Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • how can you set argv[0] to both ./foo and dir/bar Commented Mar 2, 2015 at 16:34
  • @munjal007 I'm sorry if I was being unclear. I meant running the program twice: once as ./foo and once as dir/bar. argv[0] will be different for those two cases (in each case it'll be the same as the path you used). Commented Mar 2, 2015 at 16:39
  • @munjal007 That's assuming that you run it from the shell of course. The point is that you could set argv[0] to anything when you exec*() the program yourself. It's a convention of the shell to set argv[0] to the path that was used to start the program (and it's wise to do the same when you exec*() a program, since many programs inspect argv[0] and expect it to hold the path). Commented Mar 2, 2015 at 16:43