C's strtok() and read only string literals

前端 未结 5 1496
感情败类
感情败类 2020-11-27 08:27

char *strtok(char *s1, const char *s2)

repeated calls to this function break string s1 into \"tokens\"--that is the string is broken into substr

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 09:14

    In brief:

    char *s = "HAPPY DAY";
    printf("\n %s ", s);
    
    s = "NEW YEAR"; /* Valid */
    printf("\n %s ", s);
    
    s[0] = 'c'; /* Invalid */
    

提交回复
热议问题