Computer Science, asked by rubal0125, 3 months ago

User defined function in C++ named copyupper(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT contains all words from the file FIRST.TXT in uppercase

Answers

Answered by siddharthh129
0

Answer:

void copyupper()

{

ifstream fin;

fin.open("FIRST.TXT");

ofstream fout;

fout.open("SECOND.TXT");

char ch;

while(!fin.eof())

{

fin.get(ch);

ch=toupper(ch);

fout<<ch;

}

fin.close();

fout.close();

}

Explanation:

Answered by amithadavid
0

The following C++ code gives a user-defined function in C++ named copyupper(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT contains all words from the file FIRST.TXT in uppercase

void copyupper()

{

       //input file stream to read input from a file

       //fin is the stream variable

ifstream fin;

//opening the file FIRST.TXT using open() method in input file stream

fin.open("FIRST.TXT");

       //output file stream to write the output to a file

       //fout is the stream variable

ofstream fout;

//opening the file SECOND.TXT using open() method in output file stream

fout.open("SECOND.TXT");

char ch;

       //the while loop runs till the end of file of FIRST.TXT

       //each character from FIRST.TXT is stored into 'ch' at each iteration

       //it is converted into uppercase character by using toupper() function

       //the uppercase character is then written into the file SECOND.TXT in each iteration

while(!fin.eof())

{

 fin.get(ch);

 ch=toupper(ch);

 fout<<ch;

}

       //close both the file streams

fin.close();

fout.close();

}

Similar questions