博文

目前显示的是标签为“c”的博文

One way to remember the difference between char * const pointer and const char * pointer

char * const pointer ; means that the pointer is constant and immutable but the pointed data is not. const char * pointer ; means that the pointed data is constant and immutable but the pointer is not. An easy to think it is the const modifier is always bind to the next closest thing it can. So in char * const pointer ; the const bind to the pointer variable directly, means the pointer itself can not be modified, but the value the pointer pointed to can be modified.   On the other hand, in this case const char * pointer ; the const modifier bind to *pointer, this means the *pointer(which is the value the pointer pointed to) can not be modified while as the pointer itself can be modified.

C modifier

when variable has those modifier: n/a variable outside function variable inside function default default as global, could combine with extern default as auto, local scope auto can not use outside function local scope register can not use outside function local scope but faster access static internal linkage, global to translation unit, can not combine with extern persistent vairable to function static can also be used for function, when a function use static it means it can not be used outside its translation unit, such as declared in another file.