subwaybusker
- 47
- 0
I need to initialize the arrays of an object to zero, but when I compile it, it gives me gibberish.
Here's my code:
Here's my code:
Last edited:
The discussion revolves around the initialization of 2D arrays in C++ and the issues related to unexpected output, specifically "gibberish" characters when printing values. Participants explore the potential causes of program termination and memory management issues, particularly in the context of an assignment that prohibits the use of std::vector.
Participants express varying levels of understanding regarding the initialization of arrays and the implications of pointer management. There is no consensus on the exact cause of the issues being faced, and multiple competing views on how to resolve the problems remain.
Limitations include unclear assumptions about the behavior of the getImage function and its impact on memory management. The discussion highlights unresolved issues related to the initialization of the 2D array and the handling of dynamic memory.
Readers interested in C++ programming, particularly those dealing with dynamic memory allocation, array initialization, and debugging techniques in the context of assignments or projects.
void CBin::getImage(unsigned char** destImage)
{
for(int i=0;i<height*width;i++)
{
destImage[i] = image[i];
}
}
No, it means that one of the side-effects of your error is that you obliterated the pointers to all of the rows in destImage, and replaced them with copies of the pointers to the rows in CBin::image.subwaybusker said:Does that mean one of them is redundant?