Advertisement

Parameter list?? Need a hand!

Started by April 12, 2000 10:42 PM
3 comments, last by Peddler 24 years, 8 months ago
Hey, Ok, In my main fuction I have ifstream infile; int site; int NumReadings; float average; Now in a function called Process site I am supposed to transverse the dat file infile and then return the values for NumReadings and average and also infile itself....it says to return these guys with a parameter list?? This is probably a stupid question but what is a parameter list and how do I return 3 variables from one function without making the variables global? Any help would be appreciated...thanks -Tim
sending informastion through parameter lists are usually done with pointers to original objects.

main()
{
char infile[20];
int site;
int Numreadings;
float average;

ProcessSite(infile, &site, &numreadings, &average);
}


// all pointer to the differnt types
int ProcessSite(char *SentFileName, int *SentSite, int *Sentnumreadings, float *Sentaverage)
{
fopen(SentFileName,..); // char strings are slightly different

}

Basically you are going to have to know how pointers work. With-out that knowledge you won''t get far in anything.
Get ANY book on the C or C++ basic and it''ll be in it.


ZoomBoy
A 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor and diary at
Check out my web-site
Advertisement
Thanks!

Yeah, I have basically a small library of c++ and game dev books....but I have gotten this far without reading much of them , guess I should sit down and work through em.
You might also check out references. It''s in C++ and you pass a reference to a function; it''s like an alias


ZoomBoy
A 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor and diary at
Check out my web-site
I wouldn''t use references though, if you''re going to introduce side-effects (you''re changing the values of the variables passed to the function as arguments), since it''s not as obvious (you''ll understand when you read about it)


A polar bear is a rectangular bear after a coordinate transform.

This topic is closed to new replies.

Advertisement