Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication5.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <iterator>
- #include <algorithm>
- using namespace std;
- struct cell
- {
- unsigned char operationCode;
- unsigned char operationParameter;
- unsigned int legnthToOperateOn;
- } typedef cell;
- int _tmain(int argc, _TCHAR* argv[])
- {
- ifstream myfile;
- cell cur;
- cell* cells;
- int i;
- int length;
- char* buffer;
- myfile.open("Key.bin", ios::binary);
- buffer = new char[4];
- myfile.seekg(0, myfile.end);
- length = myfile.tellg();
- myfile.seekg(0, myfile.beg);
- cells = new cell[length/6];
- // read data as a block:
- for (i = 0; i < length / 6; i++)
- {
- myfile.read(buffer, 1);
- cur.operationCode = buffer[0];
- myfile.read(buffer, 1);
- cur.operationParameter = buffer[0];
- myfile.read(buffer, 4);
- cur.legnthToOperateOn = (buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | (buffer[0]);
- cells[i] = cur;
- cout << "\ncells[" << i << "]\noperationCode: " << (int)cur.operationCode << "\noperationParametere: " << (int)cur.operationParameter << "\nlengthToOperateOn: " << cur.legnthToOperateOn << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement