现在的位置: 首页 > 综合 > 正文

关于字符数组(字符串)与二维字符数组的问题

2012年08月05日 ⁄ 综合 ⁄ 共 272字 ⁄ 字号 评论关闭

字符串 char *str = "hello world";

printf("%c", *(str+2));  结果为e

printf("%c", *(str+2)+1);  结果为f

所以*str+1与*(str+1)是不同的,前者为i,后者为e

 

二维字符数组 char *str[] = {"hello world", "i love you"};

printf("%s", *(str+1)+2); 结果为love you,从第3个字符向后输出

printf("%s", str[0]); 结果为hello world  这里str[0]等价于*str,str[1]等价于i love you

 

 

抱歉!评论已关闭.