How to create recur…
 
Notifications
Clear all

How to create recursive loop using pointers?

1 Posts
2 Users
0 Likes
361 Views
0
Topic starter

How to create recursive loop using pointers?

1 Answer
0

you want to alter a variable given in the parameter list. You can do so by using pointers. For example:

void move(int *pa)
{
    (*pa)++;  // increase the counter by one

    if (*pa < 5) move(pa);
}

void main(void)
{
    int a = 0;

    move(&a);
}
Share: