3 回答
TA贡献1817条经验 获得超6个赞
char amessage[] = "now is the time";
char *pmessage = "now is the time";
TA贡献1859条经验 获得超6个赞
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x00008000: 'n' 'o' 'w' ' ' 'i' 's' ' ' 't' 0x00008008: 'h' 'e' ' ' 't' 'i' 'm' 'e' '\0' ...amessage: 0x00500000: 'n' 'o' 'w' ' ' 'i' 's' ' ' 't' 0x00500008: 'h' 'e' ' ' 't' 'i' 'm' 'e' '\0'pmessage: 0x00500010: 0x00 0x00 0x80 0x00
char amessage[] = "now is the time";
strcpy(amessage, "the time is now");
char *pmessage = "now is the time";
strcpy(amessage, pmessage); /* OKAY */strcpy(pmessage, amessage); /* NOT OKAY */strtok(amessage, " "); /* OKAY */strtok(pmessage, " "); /* NOT OKAY */scanf("%15s", amessage); /* OKAY */scanf("%15s", pmessage); /* NOT OKAY */
pmessage = amessage;
TA贡献1946条经验 获得超3个赞
char amessage[16];amessage[0] = 'n';amessage[1] = 'o';...amessage[15] = '\0';
char *pmessage = "now is the time";*pmessage = 'p'; /* undefined behavior! */
- 3 回答
- 0 关注
- 556 浏览
添加回答
举报