C++ Programs‎ > ‎

Simple Program for Read File Operation Using C++ Programming

C++ Simple Example Programs For Beginners

Program for read the content of  a file.


STEP 1:  Start the program.
STEP 2:  Declare the variables.
STEP 3:  Get the file name to read.
STEP 4:  Using ifstreamin(filename) check whether the file exist.
STEP 5:  If the file exist then check for the end of file condition.
STEP 6:  Read the contents of the file.
STEP 7:  Print the contents of the file.
STEP 8:  Stop the program.


void main()
              char c,fname[10];
              cout<<"Enter file name:";
              ifstream in(fname);
                            cout<<"File Does not Exist";


              Enter File name: one.txt
              Master of Computer Applications