C语言给结构体指针赋值

2024-12-19 03:59:47
推荐回答(3个)
回答1:

struct student
{

char name[20];

};

void main()
{
struct student *st[99];

st[5]=(struct student*)calloc(1, sizeof(struct student));
sprintf(st[5]->name, "xyz");

}

回答2:

struct student
{

char name[20];

};

void main()
{
struct student st[99];
gets(st[5].name);
}

回答3:

st[5]="xyz";