关于指针数组里面存放了字符串的疑问

#include <stdio.h>
int main()
{	int a, b, c;
	a = 1;
	b = 2;
	c = 3;	
	char *arr[] = {"good"};	
	printf("%c\n", *arr[0]);//输出 g	
	printf("%s\n", *arr);   //输出good
	printf("%c\n", *arr[1]);//无反应 调试直接显示segmentation fault 	
	return 0;
}

我知道指针数组这样定义字符串是错误的 但是我就是想试一下

然后输出*arr[0] 程序可以运行 为什么移动一个下标后 直接无反应了?

求助

十八的先生
浏览 1169回答 2
2回答

慕设计2395807

RTCSUWLBQTWFOQMOXGCLUQODMBQMVEHDZACLHJFHDMPELAJFGCXAJSOMIRTVLNWLOEMVXNPZHKMBEBXZVLBQZCLBKZCLAQNVLPLXRUJFISBXAKIRNKFIRYBRARGJSHXZPLOKBXTDFVXUDGJTWLODGWSBKOBETWSUDSCGJTPRUDMCZBKNEOQDDQPCFQKGDSURGWMBEBBQMJSNDGPZCVDMUKMQGIYVWLBXAWGWLBLYNWSPYZVXNLPYNDSCFUXADTIYNJTPSBQMUQSIKMVRUQKDSBKFOKHWSCQYNWSURTPFMDXGCLUDTVLAIKNJZPDZISBDFNKLUJGPYJNCFOKHJXHJZRNIFVXTCFVFWSHDMIEUQADPXGCKTWZUKGNJRHWYBVKAJMHQSBXZORHWQFBQMBKMOENTVEGPFNJMIECWLBKZIKAPMDMUQMVRHCSOTJSHDFOXMCYOKMNWFUXMIRGOQTIENWRODKZIXNCLUDMWMPENJYTQYHRJSBQMOJMBESBDFVKEACFBRBDFVDMPLAEUHDSHQZBEADAEGPYUQZIEAQETVYHBRMCLNPYHDLBXNUXGOXMOXTJLOKGUDYIXTAQTVSKGIXMCYOVEAPLTQYOKTVEAIJLNQFHRAWSFVKTIKHDLHQRNPEHQSUWHHCLUCSORACMVHWYUXMIRUWMRAHWYUQTVKAWEACLHQZODTPKMPEUJSURNXGBKZCEGCSUGIRNCRNPXAJNCEUWEACKHPHPEBQZWYUXNTVSUQMPFNKFUCLHQTISVLAGBRUWGJMBEOKFOKNJZIEUQQTVRYVXMWSPZHDYHXMCEOXXNJSIENDZVRTJLBETQGPFUGUQZPLUDGWZOQNDDGWLOYNZBQGPSIXGBYAJZPRHWSISA
打开App,查看更多内容
随时随地看视频慕课网APP