美文网首页
通过结构体指针传参2020-01-23

通过结构体指针传参2020-01-23

作者: 宜居远控 | 来源:发表于2020-01-23 20:16 被阅读0次

#include <stdio.h>

#include <string.h>

int input(struct student *pst);

int output(struct student *pst);

typedef struct student //定义了一个结构体数据类型

{

  int num;

  char name[50];

  int age;

};

int main(void)

{

  student st;

  input(&st);

  output(&st);

}

int input(struct student *pst)

{

  pst->num=88;

  strcpy(pst->name,"guo");//字符串赋值用strcpy 不能直接赋值

  pst->age =16;

  return 0;

}

int output(struct student *pst)

{

printf("%d %s %d \n",pst->num ,pst->name ,pst->age );

return 0;

}

相关文章

  • 通过结构体指针传参2020-01-23

    #include #include int input(struct student *pst); int out...

  • Golang基础

    基础 定义变量 函数 循环 条件语句 指针 结构体 数组和切片 map 函数传参传函数 方法 接口 Reader ...

  • Go语言之结构体指针

    结构体本身属于值类型,可以通过指针操作结构体,编程引用类型的数据,通过new()创建指针 结构体指针

  • 6.结构体相关

    一 C 结构体和结构体指针 eg1: 一 结构体里面定义函数 通过结构体指针访问结构体里面定义的函数。 eg2:

  • 函数形参之结构体变量、指针、引用

    结构体变量作为函数形参: 输出结果:12345 Zhang San 70.0 80.0 90.0 结构体指针作为函...

  • 结构体(二)

    0. 指针和结构体 概念:通过 指针 保存 结构体变量地址struct Person { char *name;...

  • C语言20 结构体指针

    C语言20 结构体指针 探测结构体指针的特性 ++、-- 加法与减法 指针相减 使用结构体指针 结构体指针一定要指...

  • lc25 关于链表

    复习知识点:1)链表反转2)关于指针。理解C++中指针传参,大概指针传参也是传的形参(like int数字),但是...

  • C语言-5、结构体

    写法一 写法二 写法三 结构体指针 结构体指针 与 动态内存开辟 结构体的数组 结构体与结构体指针 取别名 取别名...

  • 今日小结

    指针传参 在函数间指针变量做参传值,只传地址,不附带其他信息。故以数组名为指针变量被函数调用传参后,在调用函数内s...

网友评论

      本文标题:通过结构体指针传参2020-01-23

      本文链接:https://www.haomeiwen.com/subject/ueknzctx.html