468,289 Members | 1,778 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,289 developers. It's quick & easy.

Poblem with Structural array

9
Hey, I am trying to declare an array of 12 structs that will hold information from a file input.

I have my struct

Expand|Select|Wrap|Line Numbers
  1.  
  2. struct month
  3. {
  4.     float totalRain, highTemp, lowTemp, averageTemp;
  5. };
  6.  

and this is my array

Expand|Select|Wrap|Line Numbers
  1. struct month fullYear[12];
  2.  
These are my struct variables.

Expand|Select|Wrap|Line Numbers
  1. month jan, feb, mar, april, may, june, jul, aug, sept, oct, nov, dec;
  2.  

each of the struct variables will be placed in the array respectively, but I am unsure how to read the information from the file putting them in their rightfull place.


The values in the input file will be separated by blanks. A sample single line in the input file might be:
20.1 78.2 40.1


How would I go about placing 20.1 into jan.totalRain in my array?



I hope I explained myself clearly, If not just let me know.

Thank you all for your help in advance.
Sep 3 '07 #1
1 1070
Ganon11
3,652 Expert 2GB
Access jan by using month[0], feb with month[1], ... dec with month[11]. For your operations, instead of typing jan.totalRain = /* your code here */;, type month[0].totalRain = /* your code here */;
Sep 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Brian | last post: by
2 posts views Thread by Stormkid | last post: by
10 posts views Thread by davidrubin | last post: by
2 posts views Thread by adam.spamfree | last post: by
7 posts views Thread by Mike McGavin | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.