Написать функцию, которая динамически выделит память для полей в структуре - C (СИ)
Формулировка задачи:
Доброго времени Уважаемые Гуру!
Вопрос такой:
Нужно сделать функцию которая динамически выделит память для полей в структуре.
Вот чего я наваял:
1).... ?
2)Что должна возвращать функция?
#include "stdafx.h"
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct Student
{
char * name;
int * height;
int * age;
char * address;
}Alex;
Student initStudent(char * name,int * height,int * age,char * address)
{
name=(char *)malloc(20 * sizeof(char));
height=(int *)malloc(3 * sizeof(int));
age=(int *)malloc(3 * sizeof(int));
address=(char *)malloc(20 * sizeof(char));
return ? ;
}Решение задачи: «Написать функцию, которая динамически выделит память для полей в структуре»
textual
Листинг программы
typedef struct _student
{
char *name;
int *height;
int *age;
char *address;
} Student;