To perform the write operation with in a file.

Posted by Didi Setyapramana On 7:40 PM 0 komentar

ALGORITHM:

STEP 1: Start the program.
STEP 2: Declare the variables.
STEP 3: Read the file name.
STEP 4: open the file to write the contents.
STEP 5: writing the file contents up to reach a particular condition.
STEP 6: Stop the program.
PROGRAM:



#include<iostream.h>

#include<stdio.h>


#include<conio.h>

#include<fstream.h>


void main()

{


              char c,fname[10];

              ofstream out;


              cout<<"Enter File name:";

              cin>>fname;


              out.open(fname);

              cout<<"Enter contents to store in file (Enter # at end):\n";


              while((c=getchar())!='#')

              {


                            out<<c;

              }


              out.close();

              getch();


}


Output:

Enter File name: one.txt
Enter contents to store in file (enter # at end)

Master of Computer Applications#

0 Response for the "To perform the write operation with in a file."

Post a Comment