Re: AW: [Dev-C++] reading a binary file
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Carlos d. M. <cg...@wo...> - 2002-09-05 11:29:47
|
You say char buffer, it shall be char *buffer, the function expects a poi=
nter.
Christian Wallukat escribi=F3:
> Hi List,
>
>
> i have a problem readding a binary file.
>
> I have a 1.3 MB File, and i hav to read 2048 bytes (if !=3D eof),
>
> if have tryed it with ReadFile() but i every time get an acces violatio=
n ...
>
> My last try was ifstream:
>
>
> #include "stdio.h"
> #include "fstream.h"
> #include "windows.h"
>
>
> int main(int argc, char* argv[])
> {
> char buffer;
> int nRead =3D 0;
>
> ifstream *fb =3D new ifstream;
> fb->open("c:\\out.cal");
>
> if(fb->fail() !=3D 0)printf("Cant opne\n");
>
> fb->seekg(0);
>
> while (!fb->eof())
> {
> fb->read(buffer, 2048);
> nRead =3D nRead + 2048;
> printf("%i\n", nRead);
> };
>
> 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=3Dsourceforge1&refcode1=3Dvs3390
> _______________________________________________
> 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
|