const char * ch = "123";
const char * copy;
copy = ch;
请问这里赋值的是字符串还是地址?
const char * ch = "123";
const char * copy;
copy = ch;
请问这里赋值的是字符串还是地址?
copy = ch;是把字符串“123”的首地址赋给copy。你可运行下面程序来理解:
#include<stdio.h>
int main()
{
const char * ch = "123";
const char * copy;
copy = ch;
printf("%x\n",copy);
printf("%c",*copy);
return 0;
}
程序的运行结果: