#include <iostream>
#include <fstream>
#include <string>
using std::cout;
using std::endl;
int main()
{
std::ifstream ifs("d:\\data.txt");
std::ofstream ofs("d:\\data.bak");
std::string text = "";
for (int i = 0; ifs.eof() != true; i++)
text += ifs.get();
text.erase(text.end() - 1);
ifs.close();
ofs << text;
ofs.close();
return 0;
}
/*
run:
data.txt
--------
c c++
c# java php python
data.bak
--------
c c++
c# java php python
*/