We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello every one
i am trying to create a pointer to two dimensional character array located in code space of 8051
i am getting a warning of c182:pointer to different objects
my code is like this
unsigned char code table[120][5]={some values}//array daclaration
unsigned char code **ptr;//pointer to code memory
ptr = table;//trying to access this way
can any one tell what is the mistake in it
thanks®ards ganesh
Did you copy&paste this from your code ?
If yes, then it's not a pointer to code memory. It's a pointer to a pointer. However, I'm not quite sure if it is a pointer a generic pointer in code memory, or a pointer in the default memory space to a pointer to code memory. Maybe some of the experts could clear this up.
www.danlhenry.com/.../keil_code.png
www.keil.com/.../c51_le_memspecificptrs.htm
You've fallen prey to the common misconception that pointers and arrays are fully interchangeable in C. They're not.
In particular, a pointer to an array of a multi-dimensional array is not constructed as a pointer-to-pointer-...to-element.
Correct code (setting aside the additional complication of the "code" keyword) would be any of
unsigned char (*ptr_to_whole_array)[120][5] = &table; unsignec char (*ptr_to_first_row)[5] = table; unsigned char *ptr_to_element = table[0];
thanks every one and special thanks to
Hans-Bernhard Broeker i did as u said
and i got the result
i think i got to work more on this arrays concept i previously worked on the two dimensional arrays but never faced this kind of situation
any way thanks to all of u