字符指针(char*)
一般用法
int main()
{
char ch='a';
char* pc=&ch;
*pc='b';
return 0;
}
在C语言里是没有字符串类型的,字符指针保存字符串首字母的地址。
int main()
{
char* pstr = "hello bit.";
//本质是把字符串 hello bit. 首字符的地址放到了pstr中
printf("%s\n", pstr);
return 0;
}
int main()
{
//定义数组储存在栈内
char srt[10]="abcdef";
srr[1]='g';
printf("%s\n",str);
//存放在rodata段 read only(只读)
char *str="abcdef";
*(str+1)='g';//只读段,不能被修改</