This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

void pointer behaviour ?

Hi,
I observed a strange behaviour (for me only) of void pointer. I wrote a code to access an integer through void pointer as below:

void *ptr;
int a[2] = {1,2};

ptr = (int *)&a;
ptr++; // This is giving error: Unknown Size

Why the above increment statement is giving error as i already cast the pointer to int type ?

Can anybody help me in understanding this ?

Karthik K.

Parents
  • "I want to improve my C knowledge. Can anyone suggest a way... ?"

    Do a 'C' programming course.

    Get a decent 'C' textbook.

    Probably best to learn the language on a PC or similar; then, once you know the language, you can learn how to apply it to microntrollers...

Reply
  • "I want to improve my C knowledge. Can anyone suggest a way... ?"

    Do a 'C' programming course.

    Get a decent 'C' textbook.

    Probably best to learn the language on a PC or similar; then, once you know the language, you can learn how to apply it to microntrollers...

Children