7
77123036
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream inOut( "copy.out", ios_base::in|ios_base::app );
int cnt=0;
char ch;
inOut.seekg(0);
while ( inOut.get( ch ) )
{
cout.put( ch );
cnt++;
if ( ch == '\n' )
{
ios_base:os_type mark = inOut.tellg();
/*here is an error , but if replace with
"ios:os_type mark = inOut.tellg();"
it will work well .
can you tell me why?
*/
inOut << cnt << ' ';
inOut.seekg( mark );
}
}
inOut.clear();
inOut << cnt << endl;
cout << "[ " << cnt << " ]\n";
system("pause");
return 0;
}
#include <fstream>
using namespace std;
int main()
{
fstream inOut( "copy.out", ios_base::in|ios_base::app );
int cnt=0;
char ch;
inOut.seekg(0);
while ( inOut.get( ch ) )
{
cout.put( ch );
cnt++;
if ( ch == '\n' )
{
ios_base:os_type mark = inOut.tellg();
/*here is an error , but if replace with
"ios:os_type mark = inOut.tellg();"
it will work well .
can you tell me why?
*/
inOut << cnt << ' ';
inOut.seekg( mark );
}
}
inOut.clear();
inOut << cnt << endl;
cout << "[ " << cnt << " ]\n";
system("pause");
return 0;
}