
please wait
|
|
|
|
argv[0]
is a common solution, but also unreliable. There is no standard as to what may be stored in it, other than something to the effect that it should be how the process was started. On both Windows and Unix systems, it is entirely possible that the value could point to something other than your actual executable's name. (In practice, however, this is rare.) Also, it may very well not have the full path to your executable. For example, run attaboy's code by typing different ways to start the executable:D:\prog\foo> a.exe a.exe D:\prog\foo> a a D:\prog\foo> d:\prog\foo\a d:\prog\foo\a D:\prog\foo> _ |