When I ran my program I'm getting the following Error: assignment to expression with array type
Can someone help me with this error?
I'm new to data structure.
Problem:
I'm trying to create a C program to find the average life expectancy for all High-income countries in the region Latin America & Caribbean between the periods of 1960 to 1964 and state which of those countries(s) has the greatest average of life expectancy during that stated period. The data was gathered from an excel spreadsheet.
Enable GingerCannot connect to Ginger Check your internet connectionCode:#include <stdio.h> #include <stdlib.h> struct Countries { int years; char *countryName[100]; char *countryCode[5]; char *region[200]; char *incomeGroup[100]; float lifeExpectancy; }; int main() { int i = 0, n = 16; struct Countries countries[n]; countries.countryName = "Curaçao"; countries.countryCode = "CUW"; countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Cayman Islands"; countries.countryCode = "CYM" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "St. Kitts and Nevis"; countries.countryCode = "KNA" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "St. Martin (French part)"; countries.countryCode = "MAF" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Panama"; countries.countryCode = "PAN" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Puerto Rico"; countries.countryCode = "PRI" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Sint Maarten (Dutch Part)"; countries.countryCode = "SXM" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Turks and Caicos Islands"; countries.countryCode = "TCA" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Trinidad and Tobago"; countries.countryCode = "TTO" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "British Virgin Islands"; countries.countryCode = "VGB" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Virgin Islands"; countries.countryCode = "VIR" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Chile"; countries.countryCode = "CHL" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Barbados"; countries.countryCode = "BRB" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Barbados"; countries.countryCode = "BRB" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Bahamas, The"; countries.countryCode = "BHS" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Antigua and Barbuda"; countries.countryCode = "ATG" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; countries.countryName = "Aruba"; countries.countryCode = "ABW" countries.region = "Latin American & Caribbean"; countries.incomeGroup = "High Income"; countries.lifeExpectancy = "No data"; printf(Country List\n\n"); for (i = 0; i < n; i++) { printf("Country Name %s\n", countries.countryName); printf("Country Code %s\n", countries.countryCode); printf("Region %s\n", countries.region); printf("Income Group %s\n", countries.incomeGroup); printf("Country Name %.2f\n", countries.lifeExpectancy); } return 0; }
or reload the browserDisable in this text fieldEditEdit in GingerEdit in Ginger×