標(biāo)題: 數(shù)組和指針并不相同 [打印本頁(yè)]

作者: daniu    時(shí)間: 2014-12-25 16:12
標(biāo)題: 數(shù)組和指針并不相同


作者: daniu    時(shí)間: 2014-12-25 16:12


#include<stdio.h>

void main()
{
char *ptr="123456";
char str[]="abcdef";

ptr[2]='c';//注:可以通過(guò)編譯
str[2]='3';

printf("%c\n",str[2]);// ?
printf("%s\n",str);// ?
printf("%c\n",ptr[2]);// ?
printf("%s\n",ptr);// ?
}





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1