By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

question about arrays, structures, functions

P: n/a
Good morning all. I just finished an assignment using structures. In this
assignment I used an array of structures. What I would have liked was to
use an array of structures with a function. The problem I ran into, was
when the i tried to read the data in the structure I got garbage. Normally
when I use arrays they retain the information that I enter once the function
completes. I'm thinking that it has something to do with using the
structure within the function. I was able to create the function prototype,
the function call and the function header, but I wasn't able to get any data
populated in my structures. I've include the prototype, function call and
header. Any help with understanding if and how this is possible would be
appreciated. The program I created uses an array of structures but does not
call it in a fuction so I got around having to retain the data after the
function ended.
Thanks Art

struct WeatherStats
float rainFall; //total rainfall by month
float highTemp; //high temp for month
float lowTemp; //low temp for month
float avgTemp; //avg temp for month
//function prototype for data getData
void getData(WeatherStats[], int);

//currentYear is type WeatherStatas
getData(currentYear, NUM_MONTHS); //function call to getData
//function header
void getData(WeatherStats currentMonth[], int theMonth)
Nov 25 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.