例子从网络上摘抄回来。作为备忘。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{

   typedef struct
   {
       char name[21];
       char city[21];
       char state[3];
   } Rec;

   typedef Rec *RecPointer;
   
   RecPointer rpr;

   rpr=(RecPointer)malloc(sizeof(Rec));

   strcpy( (*rpr).name, "gaojian");

   printf("name is: %s\n", (*rpr).name);

   free(rpr);

   return 0;
}

注意上面的 RecPointer 是一个指针。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
  • 2021-08-16
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2021-10-12
  • 2021-12-25
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-09-20
相关资源
相似解决方案