I am having trouble getting this to work.
I have variables initiated in main which I want to pass onto other functions and have changed. I know the only way this can be done is with pointers or to declare the variables outside the main function. I would prefer to use pointers
How is it done?
eg
int main(){
int variable1 = 5;
add(&variable1, 6);
printf("%d", variable1);
return 0;
}
int add(int *variable1, int addValue){
variable1 += addValue;
return 0;
}
I want to print 11 but I don't know how these pointers work through other functions