dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
Sep 25, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Extracting a Program's Name

The name of the executable is stored in the string argv[0]. To access it, declare your main() function as follows:

 
int main(int argc, char ** argv)

Even if the application was called without any parameters from the command-line, C++ ensures that at least one argument, namely argv[0], contains a null-terminated string with the name of the executable file. You can extract it as follows:

 
int main(int argc, char ** argv)
{
 const char prog_name = argv[0];
 cout << prog_name; // name of .exe file
}

Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date