ファイル入出力 /* * * ファイル入出力 * */ #include <iostream> #include <fstream> using namespace std; int main(){ char c = 'a'; string file_name("test.txt"); ifstream fin(file_name.c_str(), ios::binary); ofstream fout(file_name.c_str(), ios::app); if(!fin){ cerr << file_name << " create." << endl; fout.put(c); fout.close(); return 1; } fin.get(c); while(!fin.eof()){ cout << c; fin.get(c); } cout << endl; fout.seekp(fin.tellg()); fout.put(c + 1); fout.close(); fin.close(); return 0; } 結果 abcdefghijkl