Author Topic: Turbo C - Find out the current .exe filename with in the program  (Read 834 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Turbo C - Find out the current .exe filename with in the program
« on: November 28, 2011, 06:22:58 pm »
You can use command line arguments to find out the name of the .exe application which you are running.

In the following code, argv[0] refers to the complete path for the .exe file. The output would be argument[1] = c:\cmdtest.exe


Code:
//Source Code Listing


// cmdtest.c source file
 
#include <stdio.h>
 
void main(int argc, char *argv[])
{
   int i = 0;
   for(i = 0; i < argc; i++)
   {
      printf("\nargument[%d] = %s", i + 1, argv[i]);
   }
}


 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1