I want to use the read function to read a section in memory froma binary file and then to tell me what is in there as an output. But I can't seem to find out how to do this!!
Here's what I have but it's not giving me the correct answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
ptr1 = ptr1*sizeof(float);
size = data.tellg(); //This tells us the current pointer position
data.seekg(ptr1, ios::beg); // this specifys position relative to current pointer position, relative to beginning
//I hope with seek g above I am specifying to start at the beginning of the file
cout<< "This is the first pointer position not defined by user:" << size << endl;
size = data.tellg();
cout<< "this is the second pointer position not defined by user: " << size << endl;
data.read((char*) value, sizeof value);
cout << "Value 0: " << value[0] << endl;
cout << "Value 1: " << value[1] << endl;
cout << "Value 2: " << value[2] << endl;
cout << "Value 3: " << value[3] << endl;
OUTPUT:
1 2 3 4 5 6
Value 1: 0
Value 2: 6.95322e-310
Value 3: 6.95326e-310
Value 4: 6.95322e-310
Value 5: 6.95326e-310