Passing a string literal as a function parameter defined as a pointer

前端 未结 6 950
南旧
南旧 2021-02-05 20:19

I am reading the chapter on arrays and pointers in Kernighan and Richie\'s The C Programming Language.

They give the example:

/* strlen:  return         


        
6条回答
  •  醉酒成梦
    2021-02-05 20:26

    "hello, world"

    is an array of char (type is char[13]). The value of an array of char in an expression is a pointer to char. The pointer points to the first element of the array (i.e., the value of "hello, world" is &"hello, world"[0]).

提交回复
热议问题