李我远点 2017-02-21 09:17 采纳率: 71.4%
浏览 1549
已采纳

用结构体变量的指针做函数的参数

#include
#include
#include
#include

struct Student
{
int num;
char name[20];
float score[3];
float aver;
};

void main()
{
struct Student *p;
struct Student stu[10];
p = stu;
void input(struct Student *p,int n);
int n;
scanf("%d",&n);
input(p,n);

system("pause");

}

void input(struct Student *p,int n)
{
for(int i = 0;i < n;i++)
{

    接下来怎么写,我想从input 函数中 用指针输入数据
}

}

  • 写回答

2条回答 默认 最新

  • 仅仅学会简单 2017-02-21 09:51
    关注

    void input(struct Student *p,int n)
    {
    for(int i = 0;i < n;i++)
    {
    //接下来怎么写,我想从input 函数中 用指针输入数据
    p[i].num = 1;
    strcpy_s(p[i].name, "abc");
    p[i].score[0] = 2;
    p[i].score[1] = 3;
    p[i].score[2] = 4;

        p[i].aver = 3;
    }
    

    }
    上面看错,是个结构体数组

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊