Display the content of file in c through command line


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

void main()

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 looks like ..

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


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 display the content of a file using command line arguments in c Language

C program  to display content of file passing file name as  argument through command line in turbo c++

To display the content of file  we use type command in DOS ( Disk Operating System)  Make a C example program to work this type of display the content of file

Source Code

Note :

Before compiling-linking and running this C program.  create simple   .txt   (Notepad)   file in c:\turboc3\bin\apple.txt

Here create apple.txt file in c:\turboc3\bin

Write some text  content in a  file


Apple is Red
Apple is Sweet

Now Save and Exit Notepad

Execute C example program in TurboC++

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 (display.exe)  will be  generate in TURBOC3 /SOURCE Folder.





Copy one text File to another text File  in C through Command Line

How to pass command line arguments in Turbo c++

(Visited 358 times, 1 visits today)

Leave a Reply

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

Reload Image