C语言指针与数组

已知一个数组,利用数组下标和指针实现打印字符串,完成表格4。#include<stdio.h>intmain(){charweekday[][100]={"Sunday"... 已知一个数组,利用数组下标和指针实现打印字符串,完成表格4。#include <stdio.h>int main(){ char weekday[][100]={"Sunday","Monday","Tuesday", "Wednesday","Thursday","Friday","Saturday"};char *p1 = weekday;char (*p2)[7]= weekday;char *p3[7] ={weekday[0],weekday[1],weekday[2],weekday[3], weekday[4], weekday[5],weekday[6]};printf("%s\n",【1】);printf("%s\n",【2】);printf("%s\n",【3】);printf("%s\n",【4】);} 展开
 我来答
风若远去何人留
2017-12-06 · 知道合伙人互联网行家
风若远去何人留
知道合伙人互联网行家
采纳数:20412 获赞数:450132
专业C/C++软件开发

向TA提问 私信TA
展开全部
#include <stdio.h>
int main()
{
char weekday[][100]={"Sunday","Monday","Tuesday", "Wednesday","Thursday","Friday","Saturday"};
char *p1 = weekday;
char (*p2)[100]= weekday;//这里必须是100
char *p3[7] ={weekday[0],weekday[1],
weekday[2],weekday[3], weekday[4], weekday[5],
weekday[6]};
printf("%s\n",【1】);
printf("%s\n",【2】);
printf("%s\n",【3】);
printf("%s\n",【4】);
}

然后表格依次填

p1       p2[0]    p3[0]              
p1+100   p2[1]    p3[1]
p1+200   p2[2]    p3[2]
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式