C语言如何取指针数组中的某个元素的字符?
本帖最后由 kingsxiu3 于 2019-5-25 21:57 编辑char *str={
"Austria",
"United States",
"United Kingdom",
"Switzerland",
"Canada"
};
char *(*ssha)=&str;
我想用数组指针char *(*ssha)=&str 取指针数组str的第1个元素即“United States”中的“S"这个字符并且把它打印出来该如何操作 *(*(str+1)+7) #include<stdio.h>
int main()
{
char *str=
{
"Austria",
"United States",
"United Kingdom",
"Switzerland",
"Canada"
};
printf("%c\n",*(*(str+1)+7));
return 0;
}
#include <stdio.h>
int main(void)
{
const char *str =
{
"Austria",
"United States",
"United Kingdom",
"Switzerland",
"Canada"
};
const char *(*ssha) = &str;
printf("%c\n", (*ssha));
return 0;
}
感谢你的回答 解开了困扰我的问题 HUMMER军 发表于 2019-5-25 22:18
感谢你的回答哦{:5_106:}
页:
[1]