# Include "stdafx. h"
# Include <fstream>
# Include <iostream>
# Include <cmath>
Using namespace std;
// Function for reading characters from the keyboard
Void read_save (){
Char c [80];
Ofstream outfile ("f1.dat"); // open the file with an outputer
If (! Outfile ){
Cerr <"open error! "<Endl; // note that cerr is used
Exit (1 );
}
Cin. getline (c, 80); // read a line of characters from the keyboard
For (int I = 0; c [I]! = 0; I ++) // processes the characters one by one until/0 is met
If (c [I]> = 65 & c [I] <= 90 | c [I]> = 97 & c [I] <= 122) {// ensure that the entered character is a character
Outfile. put (c [I]); // saves letters to Disk Files
Cout <c [I] <"";
}
Cout <endl;
Outfile. close ();
}
Void creat_data (){
Char ch;
Ifstream infile ("f1.dat", ios: in); // open the file as input
If (! Infile ){
Cerr <"open error! "<Endl;
Exit (1 );
}
Ofstream outfile ("f3.dat"); // defines the output stream f3.dat File
If (! Outfile ){
Cerr <"open error! "<Endl;
Exit (1 );
}
While (infile. get (ch) {// when the character is successfully read
If (ch <= 122 & ch> = 97)
Ch = ch-32;
Outfile. put (ch );
Cout <ch;
}
Cout <endl;
Infile. close ();
Outfile. close ();
}
Int main (){
Read_save ();
Creat_data ();
System ("pause ");
Return 0;
}
# Include "stdafx. h"
# Include <fstream>
# Include <iostream>
# Include <cmath>
Void read_save ();
Void creat_data ();
Using namespace std;
Int main (){
Read_save ();
Creat_data ();
System ("pause ");
Return 0;
}
// Function for reading characters from the keyboard
Void read_save (){
Char c [80];
Ofstream outfile ("f1.dat"); // open the file with an outputer
If (! Outfile ){
Cerr <"open error! "<Endl; // note that cerr is used
Exit (1 );
}
Cin. getline (c, 80); // read a line of characters from the keyboard
For (int I = 0; c [I]! = 0; I ++) // processes the characters one by one until/0 is met
If (c [I]> = 65 & c [I] <= 90 | c [I]> = 97 & c [I] <= 122) {// ensure that the entered character is a character
Outfile. put (c [I]); // saves letters to Disk Files
Cout <c [I] <"";
}
Cout <endl;
Outfile. close ();
}
Void creat_data (){
Char ch;
Ifstream infile ("f1.dat", ios: in); // open the file as input
If (! Infile ){
Cerr <"open error! "<Endl;
Exit (1 );
}
Ofstream outfile ("f3.dat"); // defines the output stream f3.dat File
If (! Outfile ){
Cerr <"open error! "<Endl;
Exit (1 );
}
While (infile. get (ch) {// when the character is successfully read
If (ch <= 122 & ch> = 97)
Ch = ch-32;
Outfile. put (ch );
Cout <ch;
}
Cout <endl;
Infile. close ();
Outfile. close ();
}
C: The f1.dat and f3.dat files are generated under the Symbian8.0aS60 _ 2nd_FP2_SCProjectsTestArray project directory, and the files contain characters entered from the console each time the program runs.