double pointer vs pointer to array, incompatible pointer type

后端 未结 3 781
野性不改
野性不改 2021-01-20 16:12

Having this:

#define _DEFAULT_SOURCE 1
#include 
#include 

int main(){
    char *token, org[] = "Cats,Dogs,Mice,,,Dwarves         


        
3条回答
  •  忘掉有多难
    2021-01-20 16:36

    Address of the array references the place where the array starts, it has only the different type - pointer to the array. It is not pointer to pointer.

        char *token, org[] = "Cats,Dogs,Mice,,,Dwarves,Elves:High,Elves:Wood";
        char *pointer = org;
        while((token=strsep(&pointer,",")))
        /* ... */
    

    You cant cast reference to array to double pointer.

    restrict it a quite advanced topic. It promises the compiler that if the object referenced by pointer is modified, the access to this object can be only done by this pointer. It helps the compiler in the code optimisations

    Generally speaking I would not expect you to use this qualifier before you get proficient in the C language.

提交回复
热议问题