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)
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
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
April 25th, 2010 at 12:57 pm
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….
September 15th, 2011 at 6:35 pm
What happens if i pass the same name to source and destination? What happens if source is a shortcut(link) to destination. Your program does not handle this situation correctly.