// chapter 08
// æ åIOåº
#include
#include
#include
using namespace std;
void loading(){
for (int i = 0; i != 11; i++){
cout << "loading " << (i * 10) << "%\r" << flush;
sleep(1);
}
cout << "loaded! " << endl;
}
void file_io(){
string in_file_name = "test_in_file";
string out_file_name = "test_out_file";
ifstream infile(in_file_name.c_str());
ofstream outfile(out_file_name.c_str());
if (!infile){
cerr << "err: unable to open input file: "
<< in_file_name << endl;
}
else{
// æè¯è¯»å
// string word;
// while(infile >> word) {
// cout << word << endl;
// }
// æè¡è¯»å
string line;
while(getline(infile,line)){
cout << line << endl;
// æè¡åå
¥
outfile << line << endl;
}
}
infile.close();
outfile.close();
}
int main(){
file_io();
return 0;
}