指针基本注意点

#include "stdio.h"
#include<string.h>
int main(){

	char s[10]="verygood",*ps=s;
	ps+=4;
	printf("%p\n",ps);
	/*这里是 把字符串"nice"的首地址传递给了 ps指针,至于"nice"的存储位置,有编译器分配,不用管
	(反正有它存在的位置),而且这个字符串的值是const是常量,字符串常量,所以在其他函数中调用后不会被销毁。-
	这个是需要注意的点;
	*/
	ps="nice";
	printf("%p\n",ps);

	puts(ps);
	puts(s);
}
posted @ 2022-09-19 21:06  Development_UP  阅读(19)  评论(0)    收藏  举报