1 year ago
#307000
Tufail Gulzar
warning : assignment from incompatible pointer type ( in Delete function)
Below are two structures viz Stu and Class. I have declared array of pointers of type Class in main and passing that to Delete function so that I can deallocate the memory(using free).
When I compile this code it shows same warning on many lines like in the Delete function below.
typedef struct Stu {
struct Stu *prev, *next;
unsigned int Roll_No, Marks, Id;
char Name[20], Address[20];
} Stu;
typedef struct Class {
Stu *next;
char Class_Name[10];
unsigned int Total_Stds;
} Class;
void Delete(Class *cls[], unsigned int cha) {
unsigned int i;
Class *temp;
for (i = 0; i < cha; i++) {
printf("%s removed\n", cls[i]->Class_Name);
temp = cls[i];
cls[i] = cls[i]->next; // Warning comes here
free(temp);
}
}
int main() {
Class *cls[5];
...
Delete(cls,c);
...
return 0;
}
c
cppcheck
0 Answers
Your Answer