First if you are getting errors you don't understand, no, you don't know arrays very well at all...
Based on my previus example...
Code:
typedef struct City
{ char CityName[50];
int Population;
};
// create the array...
int CitiesSize = 10;
City Cities = malloc(CitiesSize * sizeof(City));
// open your file
CityFile = fopen(filename,"r");
// initialize a counter
int CityCount = 0;
// read your file
while ( fscanf(CityFile, "%49s %d", Cities[CityCount].CityName, &Cities[CityCount].Population))
{ CityCount++;
// manage the array
if (CityCount > CitiesSize)
{CitiesSize += 10;
Cities = realloc( Cities,CitiesSize * sizeof(City); } }
// close the file
fclose(CityFile);
printf("%d Cities loaded\n",CityCount);
That will read the file, no matter how many cities, up to the limit of memory.