Hello everyone,
I need to do a program that displays its own name.
So that, when I execute the program, let's say example.exe, "example" will be
printed on the screen.
Any ideas?
Thanks in advance
Printable View
Hello everyone,
I need to do a program that displays its own name.
So that, when I execute the program, let's say example.exe, "example" will be
printed on the screen.
Any ideas?
Thanks in advance
argv[ 0 ] may contain the name of the executable. Look up command line arguments.
Quzah.
quzah's use of the word "may" reflects the fact that the content of argv[0] -if any - is implementation defined. argv[0] may be a NULL pointer. If it is not a NULL pointer, it may yield an empty string (""), the name of an executable, a full path to the executable, or some other representation.
If argv[0] does not contain the name of the executable then the method to obtain it (eg API functions to call) is system dependent.
Yes, e.g., search for the last '\' and take the part after that.
Take a look at this tutorial It should help you implement what Laser said.
Thank you very much!