C has no idea about passing by reference and can only return one value. Thus, the traditional purpose of passing with a pointer is to allow the called function to write to a variable so that the caller can read what is written.
C ++ has the ability to pass by reference, but scanf and printf are C functions that are also available when created as C ++, so they are not available.
EDIT: explain further, even putting the variable arguments next to the problem, in the following code:
void calledFunction(int var1, int var2) { var1 = 23; var2 = 19; } void callingFunction(void) { int v1 = 9, v2 = 18; calledFunction(v1, v2); printf("%d %d", v1, v2); }
Exit "9 18". calledFunction gets local copies of v1 and v2 because C passes by value, which means that the values โโof v1 and v2 were passed, but no other link was saved in the originals. Therefore, the fact that he changes his copies does not affect the originals.
source share