-2

To be more specific, the code is like this

main()
{
  int a; int b;
  func(&a,&b);
}

void func(int *x,int *y)
{
  func1(...);    // i need to pass x,y in func1
}

void func1(int ,int ) { ... }

The arguments x,y came from my main and i dont know how to pass them to func1, in order to modify them in the scope of this function

user3794667384
  • 437
  • 7
  • 23
silinos
  • 19
  • 2
  • Do you want to pass the *values* of the pointers to `func1`, or the pointers themselves? In both cases just about [any beginners book](http://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list) will teach you how. – Some programmer dude Nov 24 '16 at 14:46

2 Answers2

0

You simply pass them on, but in order for func1 to be able to modify and pass them back you must change func1 to accept pointers.

Your prototype for func1 must be changed to:

    void func1(int* a, int* b);

Then:

    void func(int *x,int *y) {
        func1(x, y);
    }
SPlatten
  • 5,334
  • 11
  • 57
  • 128
-1

You simply have to send the adress of the variables :

 func1(&x, &y);
user3794667384
  • 437
  • 7
  • 23