This is the program i'm trying to write:
#include<stdio.h>
#include<malloc.h>
struct student {
char name[20];
float point;
};
void inputlst (struct student *sv, int n){
int i;
for(i = 0; i < n; i++){
puts("Name: "); gets((sv+i)->name);
puts("Point: "); scanf("%f", &(sv+i)->point);
}
}
void outputlst (struct student *sv, int n){
int i;
for(i = 0; i < n; i++){
puts((sv+i)->name); printf("%f", (sv+i)->point);
}
}
void main(){
struct student *classA;
int n;
printf("No. of students: ");
scanf("%d", &n);
classA = (student*)malloc(n*sizeof(student));
if(classA == NULL)
puts("Could not provide dynamic memory");
else{
inputlst(classA, n);
outputlst(classA, n);
}
}
When i ran it, i encountered these errors:
1/error: ‘student’ undeclared (first use in this function)
classA = (student*)malloc(n*sizeof(student));
^~~~~~~
2/error: expected expression before ‘)’ token
classA = (student*)malloc(n*sizeof(student));
^
What does it mean by: "‘student’ undeclared" when i already declared it in the void() function and what expression am i expected to put into my function at the specified place?