Sorry if I seem stupid for asking this but I want to reinforce my understanding and clear any misconceptions I have about user define functions.
"Case:" I have two functions (can be either void or int) which I will call them function1 and function2. I have them in a file that will be called by other programs. I have function1 as a void function called in another program and will keep being called until the program ends (function2 will not run when function1 is running).
Function2 must be executed by another program(not the same program for function1) calls for function2 (function1 must not be running in this case). Function2 can be an int or void function.
I know that the standard procedure would to put them in order in my main function since this program will call main only. The main will run in the order of the functions placed (e.g. function1 will run first then function2)
eg
#include<stdio.h>
#include<stdlib.h>
void function1(....)
int function2(...)
void function1(intA,intB,struct.....)
{
...Conditions, loops, whatever
}
int function2()
{
..........
return(some value)
}
In this part, I would have the main at the bottom
int main(int argc, char *argv[])
{
function1();
int A;
A = function2();
....
}
I thought that I would use if else conditions in main to make "Case:" possible.
Would this sample code run exactly as I mentioned at the top under Case: (with if else conditions)? If not, what am I getting confused? Example code in c would help very much as well with clear explanations.
Please tell me if there is something confusing with my explanation or my question. I will try to make it clear.
swithstatement ratherif-elseto switch to your function?