Why don't I need to dereference a character pointer in C before printing it?

后端 未结 6 1228
遇见更好的自我
遇见更好的自我 2020-12-13 11:19

Why does this code work? I would expect that I would need to dereference ptr, printf(\"%s\\n\", *ptr); before I could print it out, but I get a

6条回答
  •  伪装坚强ぢ
    2020-12-13 12:13

    *ptr is essentially a reference to a single char, not to the string of char's. due to this char * and char[] are essentially the same thing

提交回复
热议问题