I have a program that uses 3 separate files, a header file for function declarations, a cpp file for the definitions, and a main driver file to call the functions. For my function definitions, I have variables being created inside these functions that I wish to use as parameters for another function being called in main. I'm confusing myself just trying to put it into words, below is an example.
Header File
void function01(char);
void function02(int, int, char);
Cpp File
void function01(char a){
int var01 = 3;
int var02 = 4;
int var03 = 8;
char a = 'a';
}
void function02(int num1, int num2, int num3){
int sum = num1 + num2 + num3;
}
Main File
int main (void){
function02(var01, var02, var03);
return 0;
}
I know that as it is written now an error would be called. But is there anyway I can access the variables used in this first function so that I can call those same variables in main and pass them into my second function?