Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 547 Bytes

lex_string.md

File metadata and controls

14 lines (11 loc) · 547 Bytes
  • The effect of attempting to modify a string literal is undefined

    • Example:
    const char *p1 = "hello world\n"; 
    char *p2 = const_cast<char*>(p1) ;   // const_cast is already suspicious
    
    p2[0] = 'm' ;
    • Rationale *[lex.string]p8

    Ordinary string literals and UTF-8 string literals are also referred to as narrow string literals. 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 (6.6.4).