How to pass command line arguments in Turbo c++


In TurboC++ generally main function  have no arguments we write program like …

void main()
{
statements…
}

but we also passing arguments to main function
in main we passed  two arguments one is int argc and second is argv[] a character array of pointers to strings
program look like ..

void main(int argc,char * argv[])
{
statements…
}

int argc : counts total numbers of arguments passing through command prompt

char * argv[] : argv is an array of pointers to strings.

When the program is successfully  compile and executing  the strings on the command line are passed to main() function.

 

Different type definition of code

write a c program how to pass command line arguments in c Language
c program  pass arguments through command line
c example program  pass arguments through cmd prompt.

Source Code
File Name  is : cmd1.c

 

Now First compile program          ->  Alt + F9
Make link program                         ->  F9
and Last Execute/Run  program  -> Ctrl + F9

After successfully compiling and executing the program file_name.exe (cmd1.exe)  will be  generate in TURBOC3 /SOURCE Folder.

You get below message
Now Goes to FileMenu -> DOS Shell

 

Now follow this steps..

C:\TURBOC3\BIN>cd..
C:\TURBOC3>cd source

C:\TURBOC3\SOURCE>cmd1  Hello How Are You World

OR

C:\TURBOC3\SOURCE>cmd1.exe  Hello How Are You World

Output 

Command Prompt Output
Command Prompt Output

C Example in Turbo C++


Look at  Screenshot for Better Understanding

DOS SHELL in TurboC++

DOS Shell in TurboC++
DOS Shell in TurboC++

 


now get below screen……. and write following command at command prompt

Exe. File Location

Exe. File in Source Folder Source Folder
Exe. File in Source Folder

 

Now get Output on screen…..

Output

Command Prompt Output
Command Prompt Output

 

Display the content of file in c through command line

Copy one text  file to another  in c through command line

(Visited 1,236 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image