| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
a strange problem in my code
hi,
I have a new problem in my code. I try to call a function in a loop: ========================================= while( read_image ) { read_chunk(); } and the function is to do: ======================================== chunk_idat idat; idat.data_block = new unsigned char[ 8186 ]; read_image.read( (char*) &idat, (int) chunk_length ); delete [] idat.data_block; break; ========================================= the strcut is: struct chunk_idat { unsigned char flag_code; unsigned char check_bit; unsigned char* data_block; unsigned long int check_value; }; ---------------------------------------- when I executed this code, a error message wiil pop up and termined it . I found that the error is caused when the first time finished ( before the sencond time looping ) ps: the code is much longer than above, so cannnot post it |
|
#2
|
|||
|
|||
|
Hey there. I believe the problem is when you make the call to read_image.read(). The first parameter you passed in is the (char*)&idat, try passing the (char*)&idat.data_block instead. Hope this helps.
|
|
#3
|
|||
|
|||
|
well, I found the problem is when I "new" a size to "unsigned char* data_block;"
If I use a fix number then there is no problem occured. here are my code ( I am writing a program to read and write PNG files) please help me to solve the problem ( I changed the code structure from using "struct to class" ) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > a strange problem in my code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|