Read a text file and write it to a target text file, changing all lowercase to uppercase and double-spacing the output text.
Read a text file and write it into the target file. The target file converts all lowercase letters into uppercase letters and outputs the text with double line spacing.
Name.txt
Fanzhaoxin
Bush will
Sadamu
Micro jaoden
// BookProgramAfter compilation and compilation under vcsp6, the user creates a name.txt file and writes the file to name2.txt.
# Include <fstream>
# Include <cstdlib>
# Include <iostream>
Using namespace STD;
Void double_space (ifstream & F, ofstream & T)
{
Char C;
Char D;
While (F. Get (c ))
{
If (C> = 'A' & C <= 'Z ')
{
D = c-32;
T. Put (d); // Replace the case
}
If (C = '\ n ')
{T. Put (C );
T. Put (c); // when a carriage return occurs, two carriage returns are output to achieve double line spacing.
}
If (C <97 & C! = '\ N' | C> 122 & C! = '\ N ')
T. Put (C );
}
}
Int main ()
{
Ifstream f_in;
Ofstream f_out;
F_in.open ("name.txt", IOS: In); // read a file with a name, in the TXT format.
F_out.open ("name2.txt", IOS: Out); // output a file with the name saved, with double line spacing. Replace lowercase with uppercase letters.
If (! F_in)
{
Cout <"cannot open" <Endl;
Exit (1); // can not open return wrong
}
If (! F_out)
{
Cout <"cannot open" <Endl;
Exit (1); // The same as f_in
}
Double_space (f_in, f_out); // use the function to achieve your goal
Return 0;
}