Re: AW: AW: [Dev-C++] reading a binary file
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2002-09-05 12:41:38
|
Make the following changes, and it will work. A pointer is just that. A pointer to a block of memory. To use it, you also must make the pointer point to some available memory. An unininitalized pointer may point anywhere inside the computer, thereby resulting in a crash when the program tries to follow the pointer for either reading or writing. Cheers /Per Westermark EMA System email: pw...@ia... Per Westermark web: http://iapetus.neab.net Vargvaegen 174B phone: +46 8 410 17 198 S-906 42 Umeaa Sweden On Thu, 5 Sep 2002, Christian Wallukat wrote: > Hi Carlos , > > > sorry, but i send the wrong snipped (one of the trys)... > > If I execute it as follows, it crashes... > > Any idea ? > > > > > > #include "stdio.h" > #include "fstream.h" > #include "windows.h" > > > > int main(int argc, char* argv[]) > { > BYTE * buffer; > int nRead = 0; > > buffer = new BYTE[2048]; > ifstream *fb = new ifstream; > fb->open("c:\\out.cal"); > > > if(fb->fail() != 0)printf("Cant opne\n"); > > > fb->seekg(0); > > > while (!fb->eof()) > { > fb->read(buffer, 2048); > nRead = nRead + 2048; > printf("%i\n", nRead); > }; delete[] buffer; > > > getchar(); > return 0; > } > > > > If I execute this I get an acces voilation after the read function ... > > > > Does any one have an idea ? > > > > Kind r > > > > Christian > > > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=sourceforge1 > <https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390> > &refcode1=vs3390 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > <http://www.noicys.cjb.net/devcpp/ub.htm> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > <https://lists.sourceforge.net/lists/listinfo/dev-cpp-users> > > > > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |