This is my example code:
#include <stdio.h>
void Func(int a[], int b) {
a[b] = 1;
b += 5;
}
int main(void) {
int a[10];
int b = 0;
printf("%d\n", b);
Func(a, b);
printf("%d\n", a[0]);
printf("%d\n", b);
}
And I want the program to print:
0
1
5
I've tried changing the function by making b
a pointer:
void Func(int a[], int *b)
... and by writing *b += 5
. Also, I've changed the call of the function to:
int a[10];
int *b = 0;
// ...
Func(a, &b);
Is it possible to manipulate b
and to use it?
Note: I've tried following this post