Code:
void releaseMemory ( COUNTRY *list )
{
// Local Declarations
int i;
// Statements
for ( i = 0; i <= 21; i++ )
{
free ( list[i].id );
free ( list[i].name );
free ( list[i].capital );
free ( list[i].population );
}
return;
}
Where does this magic 21 come from? free()'ing non-NULL pointers that you didn't allocate is very bad.
Also don't use gets() -- see the FAQ.