I think the issue was by ths following , There are a couple of problems with your code: ostream::seekp sets the "put" pointer, i.e. the location at which one writes data, not the position at which one reads data. Use istream::seekg to set the "get" pointer ostream::tellp doesn't perform any I/O. It merely reports the value of the 'put' pointer, it doesn't actually fetch the data stored there. You mean to use istream::get.
cout<<"Value at offset 0x16: "<<myvar << "\n";
should help you out basic_fstream is derived from basic_iostream which is derived from basic_istream and basic_ostream. So, basic_fstream has function seekp from basic_ostream and function seekg from basic_ifstream. In short, in your case, calls to seekp and seekg do same actions, since actions perfomed by basic_filebuf::seekpos depends only on open mode for basic_filebuf.
basic_ostream<charT,traits>& seekp(pos_type pos);
pos_type seekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out);
I hope this helps you . i was compiling in visual studio 2010 , and when i took the same code and compiled it on other ides like code blocks , it works fine and outputs the expected results i think it is a .Net issue or something !