hello, i am attemping to write a basic swf header reader using the format specification from : http://www.the-labs.com/MacromediaFlash/SWF-Spec/SWFfileformat.html
So far i am able to read the first 3 bytes : FWS, no problem
The problem i am having is reading the version number after, it is displayed as a question mark in the command prompt.
I have tried casting the version number to an unsigned int from char but it still does not display correctly, it becomes avery large number:
FWS?
Converted ? is : 429467177, and 137 as a signed char.
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
typedef unsigned char byte;
int main () {
int length;
char * buffer;
ifstream is;
is.open ("test.swf", ios::binary );
// get length of file:
is.seekg (0, ios::end);
//is.tellg() length = istellg() for whole file
length = 8; //one for single bit
is.seekg (0, ios::beg);
// allocate memory:
buffer = new char [length];
// read data as a block and assig it to buffer:
is.read (buffer,length);
char newchar = buffer[4]+buffer[5]+buffer[6]+buffer[7];
unsigned int Int32 = (char)newchar; //casting to integer
//version = buffer.copy(version,1,2);
is.close();
cout.write (buffer,length); //full byte read in
cout << "\n"<<Int32; //the type cast part
delete[] buffer;
return 0;
}
Im sure this is a casting problem, as it it stored according to the specification as an unsigned 8 bit integer. (Version UI8 Single byte file version) but i am unsure about how to cast it to its real value. Any help would be ace :)