下面的程序是从一个图片文件中读取数据,在Ultraedit中前两个字节明明显示为
42 4D,但是用下面的程序读出来之后就变成了 47 49。求大佬指教。
#include
#include
using namespace std;
void ReadBmp(string bmpname){
string BmpName = bmpname + ".jpg";
ifstream fin;
fin.open(BmpName.c_str(), ios::binary);
if(!fin.is_open()){
cout << "file can not be opened\n";
return ;
}
cout << hex;
cout << 15 << endl;
int x = fin.get();
cout << x << " ";
x = fin.get();
cout << x << " ";
}
int main(){
ReadBmp("FLOWER");
return 0;
}