nold - You're a moron. Of course I know how to use return(). I also know how to use a microwave. Do I need to post instructions on how to do that to make you believe me?
money? - You're a moron, but at least you (almost) know what you're talking about.
martman00 - Good job trying to help
I got sick of reading through the God-forsaken grammarless flame-bait that is this thread, and just skimmed. So I'm not sure if the original poster understands return yet or not. So I'm going to post an analogy-type thing with an explanation, hoping that it will be of some use. Nold, you better read it too, because you seem to have very little idea about what you speak.
A function (usually) accepts some values, like this
Code:
int function(char value1, float value2)
The values that function() accepts in my example are value1 and value2. Then, function() will do some things with the values it is given, possibly calling other functions in the process. After it is all done doing it's thing to the values it was given, it is allowed to return one, and only one, value to the function that called it (main, for example) For the example above, that value will be of type int. Normally, what is returned will be either be a value indicating the result of all the hard work done in the function, or a value indicating that the function either failed or succeeded in doing what it was supposed to do. Now, to hopefully clarify this just a little bit more, I'm going to provide some sample code (there was some other good sample code given before, but it was stuck in with a bunch of flaming and other code that wasn't good)
Code:
#include <iostream>
using namespace std;
int add(int a, int b)
{
cout<<"in function add();"<<endl;
return (a+b); //add a+b and return it as the value of this function
}
int main()
{
int num1 = 7;
int num2 = 4;
int result;
cout<<"in main();"<<endl;
cout<<"calling add();"<<endl;
result=add(num1,num2);
cout<<"back in main();. Add returned this value:"<<result;
return 0; //return from main exits the program and gives a value to the operating system
}
I hope that was of help.