要给结构体 struct *Student 赋值,可以通过以下步骤进行:

  1. 定义一个结构体 struct Student,包含需要的成员变量。比如:
struct Student {
    int id;
    std::string name;
    int age;
};
  1. 创建一个结构体指针 struct *Student,并分配内存空间。比如:
struct Student *student = new struct Student;
  1. 使用指针访问成员变量,并给它们赋值。比如:
student->id = 1;
student->name = 'John';
student->age = 20;
  1. 最后,记得在使用完后释放内存空间。比如:
delete student;

原文地址: https://www.cveoy.top/t/topic/p4Mc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录