by moonchild · 5y ago · 0 comments
> if you want to modify a value you either have to use a pointer to the memory address:
void increment_a(int *a)
{
*a++;
}
int solve(void)
{
int a = 5;
increment_a(&a);
} *a++
doesn’t increment the value pointed to by `a`, it increments `a` itself. The value remains intact. int increment(a)
{
return a+1;
}
void somefunc()
{
int b = 5;
b = increment(b);
printf("b now %d\n", b);
}Noob mistake