#include <stdio.h> int main () { char* s = "hello"; // 字符串名字就是首地址 printf("%x\n",s); // s是char指针,size = 4 or 8 printf("sizeof s is %d\n", sizeof(s)); // 解引用第一个地址得到的是h printf("%c\n",*s); // 解引用第二个地址得到的是e printf("%c\n",*(s+1)); int i = 0; while (1){ // 字符串结尾是'\0', 遇到结尾就结束 if (*(s+i) == '\0'){ break; } printf("%c\n",*(s+i)); i++; } return 0; }
标签:int,C语言,char,地址,printf,类型,sizeof From: https://www.cnblogs.com/shunguo/p/17730653.html