While trying to understand why pointers are actually used and for what, I created a little test program. The above code is supposed to simulate a tube magazine for a tube that can be filled with tennis balls. Basically if a new Ball is loaded, the complete row is being pushed back. The code works as intended, however I get the following error in the line marked:Code:int tube_mag[6] = {0,0,0,0,0,0}; int *pMagPointer = &tube_mag[5]; void LoadBall() { if (tube_mag[6] == 0) { pMagPointer = &tube_mag[5]; tube_mag[6] = *pMagPointer; //Error this line pMagPointer = &tube_mag[4]; tube_mag[5] = *pMagPointer; pMagPointer = &tube_mag[3]; tube_mag[4] = *pMagPointer; pMagPointer = &tube_mag[2]; tube_mag[3] = *pMagPointer; pMagPointer = &tube_mag[1]; tube_mag[2] = *pMagPointer; tube_mag[1] = 1; DisplayMenu(); }
However the compiler lists the compilation as "successful". Also I did only post the relevant parts of the code (initialization of the pointer and array) and the function they are used in.C4789: destination of memory copy is too small



LinkBack URL
About LinkBacks


