0
Reading the value of a pointer from a function
double function (int x,int* pointer){ int address; /*this is the variable I want my pointer value to be saved in*/ pointer=&address; if(x==0) *pointer=1; else *pointer=0; return x; /*function does not return a pointer, but something else*/ } int main(){ int address; function(0,&address); printf("%d",address); } This code is a part of a larger code, but I'm only having problem with this part, so forgive me if it doesn't make much sense. How do I read the value of a pointer from a function and print it?
3 Respostas
+ 2
mel1705 What is this code from?
I hope it's not from something being built by professional developers. I'd be worried to see the rest of the code base.
+ 2
Ah... I thought you were fixing someone else's code.
+ 1
David Carroll no, this is part of my assignment, I am a beginner. And this is just a snippet I made to present a problem, not a real part of the code.