Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

i was wondering if we can do this in c........... we can write a function to change the value of a variable like .... void change(int *x) { *x=3; return; } and call wud be smthin like change(&x); can we do the same for an array?

OpenStudy (anonymous):

I don't see any reason why not. It will still be a pointer to memory.

OpenStudy (anonymous):

can u write some code for me?

OpenStudy (anonymous):

void change(char *x) { *x[1]='foo'; return; }

OpenStudy (anonymous):

umm lemme see if that works

OpenStudy (anonymous):

it's not working

OpenStudy (anonymous):

and the error is?

OpenStudy (anonymous):

Have you tried void change(char *x) { x[1]='foo'; // <-- without the * return; }

OpenStudy (anonymous):

by the way... the calling function will be change(foo) not change(&foo)

OpenStudy (anonymous):

ooo

OpenStudy (anonymous):

that wont worjk either

OpenStudy (anonymous):

no worries got it covered and it's not

OpenStudy (anonymous):

............

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!