File input/output operation

Simple Program for Write File Operation Using C++ Programming
#include<iostream.h>

#include<stdio.h>

#include<fstream.h>

#include<conio.h>

void main()

{

char c1,fname_1[10];

ofstream out;

cout<<“Enter File name:”;

cin>>fname_1;

out.open(fname_1);

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

while((c1=getchar())!=’#’)

{

out<<c1;

}

out.close();

getch();

}

Output:
Enter File name: one.txt

Enter contents to store in file (enter # at end)

Master of Computer Applications#

Simple Program for Read & Write File Operation (Convert lowercase to uppercase) Using C++ Programming

#include<string.h>

#include<stdio.h>

#include<iostream.h>

#include<conio.h>

#include<ctype.h>

#include<fstream.h>

void main()

{

char c1,u1

; char fname[10];

clrscr();

ofstream out;

cout<<“Enter File Name:”;

cin>>fname;

out.open(fname);

cout<<“Enter the data you want (Enter # at end)\n”;

while((c1=getchar())!=’#’)

{

u1=c1-32;

out<<u1;

}

out.close();

ifstream in(fname);

cout<<“\n\n\t\tThe File data\n\n”;

while(in.eof()==0)

{ in.get(c1);

cout<<c1;

}

getch();

}

Output:
Enter File Name:Three.txt

Enter the data you want (Enter # at end) prosofttek corporation

The File data PROSOFTTEK CORPORATION

Simple Program for Read File Operation Using C++ Programming
#include<conio.h>

#include<fstream.h>

#include <iostream.h>

void main()

{

char c1,f_name1[10];

clrscr();

cout<<“Enter file name:”;

cin>>f_name1;

ifstream in(f_name1);

if(!in)

{

cout<<“File Does not Exist”;

getch();

return;

}

cout<<“\n\n”;

while(in.eof()==0)

{

in.get(c1);

cout<<c1;

}

getch();

}

Output:
Enter file name: three.txt

PROSOFTTEK CORPORATION

 

Leave a Reply

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