C++ string literal data type storage

前端 未结 8 1082
一生所求
一生所求 2020-11-30 10:03
void f()
{
    char *c = \"Hello World!\"
}

Where is the string stored? What\'s the property of it? I just know it is a constant, what else? Can I

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 10:42

    §2.14.15 String Literals, Section 7

    A narrow string literal has type “array of n const char”, where n is the size of the string as defined below, and has static storage duration.

提交回复
热议问题