Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- int main(int argc,char *argv[])
- {
- if(argc!=2)
- {
- cout << "argument error" << endl;
- return 1;
- }
- ifstream file (argv[1], ios::in|ios::binary);
- //ifstream fin( outfile, ios::in | ios::binary );
- if (!file)
- {
- cout << "Can not open file";
- return 1;
- }
- //unsigned int d;
- unsigned char d;
- int number=0;
- while(!(file>>d).eof())
- {
- number=number+1;
- file.read((char *)&d, sizeof(unsigned char) );
- //file.read(&d, sizeof( unsigned char ) );
- //cout << hex << setw(2) << setfill('0') << static_cast<unsigned int>(d);
- cout << number <<":";
- cout << (unsigned int)d << endl;
- //cout << static_cast<unsigned int>(d)<<endl;
- //cout << (int)(int8_t)d<<endl;
- // cout << d << endl;
- }
- file.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment