How do I read and store string of arbitrary length using malloc and realloc in C?

后端 未结 4 1447
生来不讨喜
生来不讨喜 2021-01-22 03:53

I have a structure

typedef struct store
{
   char name[11];
    int age;
} store;

and a main function(below is part of it):

int         


        
4条回答
  •  余生分开走
    2021-01-22 04:14

    Change the name[11] to *name; Allocate memory for that everytime using malloc.

    By the way, register is a keyword in C language. You can't use it like you did !

提交回复
热议问题