int main()
{
char ch = 'w';
char* pc = &ch;
char* p = "abcdef";//把首字符a的地址放在p里面
printf("%c\n","abcdef"[3]);//打印字符d,"abcdef"相当于arr
return 0;
}
#include <stdio.h>
int main()
{
char str1[] = "Hello";
char str2[] = "Hello";
const char* str3 = "Hello";
const char* str4 = "Hello";
if(str1 == str2)
printf("1 to 2 the same\n");//1和2申请的空间不一样
else
printf("1 to 2 unsame\n");
if(str3 == str4)
printf("3 to 4 the same\n");//此时 "Hello"为常量字符串,3 和 4 都指向的常量字符串H的地址
else
printf("3 to 4 unsame\n");
if(&str3 == &str4)
printf("&3 to &4 the same\n");
else
printf("&3 to &4 unsame");
return 0;
}
1 to 2 unsame
3 to 4 the same
&3 to &4 unsame