View Single Post
Old 04-18-2005, 08:59 AM   #1 (permalink)
JaySun
Registered User
 
Join Date: Mar 2005
Posts: 7
JaySun is on a distinguished road
Question Structures and Arrays in C

I am supposed to create a structure and an array that will hold 4 occurences of the structure. I am having a difficult time with assigning the values to the array. Yes this is a class assignment, I really do not need to hear about hurricanes these days! Here is a bit of the code:
Code:
 #include <stdio.h>
 
 int main (void)
 {
 	struct hurricane
	{
		char hurricane_name[10];
		int category;
		int max_windspeed;
		char month[10];
		int day;
		char landfall[20];
	}h[4];
	
	h[0].hurricane_name[10] = "Charley";
	h[0].category = 4;
	h[0].max_windspeed = 145;
	h[0].month = "August";
	h[0].day = 13;
	h[0].landfall = "Charlotte Co.";
     
        return 0;
}
The code further goes on to add 3 more hurricanes into the array and then just print them out (which I have no issue with). Why is my syntax wrong. As always help is appreciated!
JaySun is offline   Reply With Quote