Search code examples
cpointersvolatile

What's meaning of these volatile with pointers in C ?


volatile void * ptr;

Whether ptr is volatile or it points to the volatile location.

So the actual doubt is : Is the same thing applied to the above declaration as it applied with const qualifier ?

Little explanation will help me a lot.


Solution

  • It's a pointer to volatile data. If the pointer itself should be volatile but not the data it points at, you'd use:

    void * volatile ptr;
    

    So yes, it works the same way as the const modifier.