Guest User

Untitled

a guest
Oct 17th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. // readlst.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. struct trigger
  5. {
  6.     unsigned int buffID;
  7.     unsigned int triggerID;
  8.     char data[76];
  9. };
  10.  
  11. using namespace std;
  12. int _tmain(int argc, _TCHAR* argv[])
  13. {
  14.     fstream listFile;
  15.     vector<trigger> Data;
  16.     unsigned int size;
  17.  
  18.     //vector<unsigned char> outbuff;
  19.  
  20.     unsigned int first;
  21.  
  22.     listFile.open("tagbufftrigger.lst", fstream::in|fstream::binary);
  23.  
  24.     if( !listFile.good() )
  25.     {
  26.         cout<< listFile.good() <<endl;
  27.         return 0;
  28.     }
  29.  
  30.     //Get the file size
  31.     listFile.seekg(0, ios::end); //seek to the end
  32.     size = listFile.tellg(); // get the length
  33.     listFile.seekg(0, ios::beg); // seek back to beginning
  34.  
  35.     cout<< "Size of file is "<< size << endl;
  36.     //seeking forward for now.
  37.     listFile.read( (char*)&first, sizeof(unsigned int) );
  38.     cout<< "First four is: "<< first << endl;
  39.  
  40.     //Data.resize(first);
  41.  
  42.     for( unsigned int i = 0; i < first; ++i )
  43.     {
  44.         listFile.read( (char*)&Data[i], sizeof(trigger));
  45.     }
  46.    
  47.  
  48.     vector<trigger>::iterator it = Data.begin();
  49.     for( it; it != Data.end();++it)
  50.     {
  51.         cout<< "BuffID: " << hex << it->buffID << endl;
  52.         cout<< "triggerID "<< hex << it->triggerID << endl;
  53.         cout<< endl;
  54.     }
  55.  
  56.     listFile.close();
  57.     return 0;
  58. }
Add Comment
Please, Sign In to add comment