What's wrong with the function call? When i do lSearch(V, size, key) iam just passing key by value, and lSearch has an int to receive not a pointer, why is it whining?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct
{
int num;
char name[80];
float mark;
}Student;
int lSearh(Student *V, int size, int key)
{
int i=0;
while((i<size) && (V[i].num<key))
{
i++;
}
if((i<size) && (V[i].num==key))
{
return i;
}
else
{
return -1;
}
}
Student *RemoveStudent(Student *V, int *size, int key)
{
int i, j;
i = lSearch(V, size, key); //Error here with key
for(j=i;j<*size;j++)
{
V[j]=V[j+1];
}
*size=*size-1;
V = (Student *)realloc(V, (*size)*sizeof(Student));
if(V == NULL)
return NULL;
return V;
}