my_routine()
{
do stuff here and set a value
I forget how I return it, but I am 99% sure I have it right.
}
That's not how you "call" a function. To call a function you would do something like this:
int a;
a = my_routine();
So a would be set to the return value of my_routine. What you have above looks more like a function implementation, but you're missing a return type. This is would the implementation should look like:
void my_routine() {
// Do stuff
}
The above doesn't return a value (hence the void). If you want to return, say an int, you would do this:
int my_routine() {
// Do stuff
return someInt;
}
Again, this is only the implementation. This is placed somewhere in your code, outside of all other functions and only done once.
my_variable my_routine();
This sets "my_variable" to the value returned by "my_routine"
Incorrect, that looks more like a function prototype, assuming my_variable was a variable type, rather than a variable. To call a function that returns a value and store it in a variable, you would do this:
int my_variable;
my_variable = my_routine();
Keep in mind, my_routine() would need to be implemented (like the example above) somewhere in your code.
Some of the routines have values in the () like:
void their_routine(int blah)
So if I want to include my variable, what would I do to it?
void their_routine(int blah, int my_variable)
Variables inside the parenthesis are passed to the function that you are calling. They are then used in whatever calculations need to be done within that function. They are passed by value, meaning the value of the variable is not manipulated.
Here's an example of code that uses both arguments and return variables:
int kelvin, celsius;
kelvin = getTemperature();
celcius = convertToCelcius(kelvin);
This of course, assumes getTemperature() and convertToCelcius() are implemented somewhere in the code.