What does while(*pointer) means in C?

后端 未结 5 2093
心在旅途
心在旅途 2020-12-15 12:45

When I recently look at some passage about C pointers, I found something interesting. What it said is, a code like this:

char var[10];
char *pointer = &v         


        
5条回答
  •  余生分开走
    2020-12-15 13:30

    *pointer means dereference the value stored at the location pointed by pointer. When pointer points to a string and used in while loop like while(*pointer), it is equivalent to while(*pointer != '\0'): loop util null terminator if found.

提交回复
热议问题