i'm writing a program that reverses the first 600 characters of a bitmap picture (it basically swaps character 0 with char 599, 1 with 598 and ......)
This is what i've written so far but it's not working
#include <iostream.h>
#include <fstream.h>
#include<conio.h>
int main()
{
char c1,c2;
int i,j;
fstream pic;
pic.open("mry.bmp", ios::in|ios::out| ios::binary);
if(!pic)
{
cout<<"Error! "<<endl;
return 1;
}
for( i=0,j=600; i<j; i++,j--)
{
pic.seekg(i);
pic.get(c1);
pic.seekg(j);
pic.get(c2);
pic.seekp(i);
pic.put(c2);
pic.seekp(j);
pic.put(c1);
}
getch();
return 0;
}
can anyone give me a clue on why it's not working and how it could be improved