Mega Code Archive
Uses both seekp( ) and seekg( ) to reverse the first num characters in a file
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
if(argc!=3) {
cout << "Usage: Reverse \n";
return 1;
}
fstream inout(argv[1], ios::in | ios::out | ios::binary);
if(!inout) {
cout << "Cannot open input file.\n";
return 1;
}
long e, i, j;
char c1, c2;
e = atol(argv[2]);
for(i=0, j=e; i