Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command-line parameters????

Status
Not open for further replies.

metamorphy

Programmer
Dec 16, 2001
34
US
Greetings,

What is the method for getting my program to accept an integer as a command line parameter so that I could run it
from the dos prompt like this:

myprog.exe 10

and get the integer 10 from the command line. Thanks for the help...
 
#include <stdlib.h>
#include <stdio.h>

void main( int argc,char* argv[] )
{
int i;

if( argc==2 )
{
i=atoi( argv[1] );
printf( &quot;%d\n&quot;,i );
}
} Mike L.G.
mlg400@blazemail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top