why I am trying to dynamically allocate memory for this pointer to array of structure
I have STUDENT *studArr[]
where STUDENT is the name of the structure
I tried to allocate like this
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "queue.h"
#include "stack.h"
#define NAME_SIZE 20
#define RECORDS_SIZE 100
typedef struct STUDENT
{
char studName[20];
int timeEnter;
int timeUpdate;
}STUDENT;
typedef struct TUTOR
{
char tutorName[NAME_SIZE];
int tutorTime;
STUDENT *ptr;
}TUTOR;
QUEUE *queue1;
STACK *stack1;
void getData(STUDENT *studArr[]);
int main(void)
{
STUDENT *studArr[100];
getData(studArr);
return 0;
}
void getData(STUDENT *studArr[])
{
FILE *fp;
char fileName[NAME_SIZE];
int first;
int i;
printf("Enter the file name: ");
gets(fileName);
fp = fopen(fileName, "r");
if (fp == NULL)
{
printf("Error opening file!\n");
return;
}
fscanf(fp, "%d", &first);
**studArr = malloc(sizeof(STUDENT*)*first);
}
But I got an error saying no operator "=" matches these operands
why am I getting this error and how can I fix the error?
thank in advance