> 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;
>
>
> 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);
> };
>
>
> getchar();
> return 0;
> }
>
>
>
> If I execute this I get an acces voilation after the read function ...
>
>
>
> Does any one have an idea ?
Greets, Christian.
The problem is that you haven't allocated memory for the buffer. You say
char *buffer. How big should it be? The compiler has no idea. Replace it
with char buffer[2048] or, better yet, allocate it on-the-fly using `new'.
___________________________________________________________
Abhijit Shylanath
E-mail: mu...@gm... || ibr...@bi...
Web-site: http://mudeth.tripod.com/
|