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】);}
展开
1个回答
展开全部
#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]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询