So I have 3 files: main.c,countries.h and countries.c
I declare pointer of the structure called "Country" in the countries.h
I have included the countries.h in countries.c and in main.c
and declared the structure its self in countries.c
countries.h
typedef struct Country* pCountry;
countries.c
struct Country {
char *name;
pCity cities;
int numCities;
pTerritory countryTerr;
};
now, I want to create array of pointers of the Country structure, using malloc
so I did that:
pCountry countries_array;
countries_array = (pCountry);
malloc(num_of_countries*sizeof(countries_array));
and to assign pointers to each pointer,even though the malloc, does seems to work I cant
assign pointers to the elements in the array using []:
countries_array[0]= new_pointer;
I get "invalid use of undefine struct country" and "derefrecing pointer to incomplete",
what is the problem with the code?
thanks
mallocitselfs returns the pointer, NULL if there is no memory available like:countries_array = malloc(num_of_countries*sizeof countries_array);countries_array = (pCountry);supposed to mean? Was that intended to be a type cast of the result of the next line?country_arraylooks like?