function to initialize variables in C -


I should use a function to provide the initial value of the variable, but I do not understand that my code Why does not the init function in? In order to start A, B, C, it gives some garbage numbers. In addition, I should use a rotating function using the static declaration of variables, A, B, C, but it does not swap the variable due to its stabilization. How do i do this

  zero init (int number 1, int number 2, int number 3); Int main (zero) {int a, b, c; Init (a, b, c); Printf ("a =% d, b =% d, c =% d \ n", a, b, c); turn by turn (); Return 0; } Zero init (int num1, int num2, int num3) {printf ("Enter value for num1:"); Scanf ("% d", & number1); Printf ("Enter value for num2:"); Scanf ("% d", & amp; NUM2); Printf ("Enter value for num3:"); Scanf ("% d", & amp; num3); } Zero rotation (zero) {static int a, b, c; Int temporary; Temporary = a; A = b; B = C; C = temp;}  

Your function value .
However, how to allow address only function in C to change it.

Your use of the function arguments can be corrected in this way ... Change the function:

  zero init (int * num1, int * num2, int * Num3 } {Printf ("Enter value for num1:"); Scanf ("% d", num1); // Because the argument is already a // pointer, you do not need de-reference (& amp;) printf ("Enter value for num2:"); Scanf ("% d", NUM2); Printf ("Enter value for num3:"); Scanf ("% d", num3); }  

And, change the call:

  init (a, b, c); From  

to:

  init (and a, & amp; b and c);  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -