AIM
A program to copy one file to another file and convert the lower case characters to upper case characters.
ALGORITHM
1) Start the process
2) Create the input file and out put file.
3) Get the input file name to fname1.
4) Get the output file name to fname2.
5) Open the infile(fanme1)
6) Check if infile.fail()
a) True:
i) Execute error conversion
ii) exit
7) open the outfile(fanme2)
8) check if outfile.fail()
a) repeat step(6:a)
9) check while infile.eof()
a) True:
i) Ch?(char)infile.get()
10) Close both files
11) Stop the process.
PROGRAM :
#include<iostream.h> #include<conio.h> #include<iomanip.h> #include<stdlib.h> #include<ctype.h> #include<fstream.h> void main( ) { ofstream outfile; ifstream infile; char fname1[10],fname2[20]; char ch,uch; clrscr( ); cout<<"Enter a file name to be copied "; cin>> fname1; cout<<"Enter new file name"; cin>>fname2; infile.open(fname1); if( infile.fail( ) ) { cerr<< " No such a file Exit"; getch(); exit(1); } outfile.open( fname2); if(outfile.fail( )) { cerr<<"Unable to create a file"; getch(); exit(1); } while( !infile.eof( ) ) { ch = (char) infile.get( ); uch = toupper(ch); outfile.put(uch); } infile.close( ); outfile.close( ); getch( ); } |
OUTPUT:
Enter a file name to be copied.
C:\text1.txt
Enter new file name
D:\new.txt
Input file
Asbcdefghijklmnopqrstuvwxyz
Output file
ASBCDEFGHIJKLMNOPQRSTUVWXYZ
Hi all, how to call a program from another program and how to execute
more than one function at a time.
I am new to c++ concepts, so please any one help me by providing
code….
i need more explanation
this program is not exicuted
Yes, you may visit this site if you have a simple wish.
http://www.secufoon.com/program-for-data-copy-from-one-file-to-another-file-in-cc-language/
Yes, you may visit this site if you have a simple wish.
http://www.secufoon.com/program-for-data-copy-from-one-file-to-another-file-in-cc-language/