A community for students.
Here's the question you clicked on:
 0 viewing
A.Avinash_Goutham
 3 years ago
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?
A.Avinash_Goutham
 3 years ago
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?

This Question is Closed

Chris2332
 3 years ago
Best ResponseYou've already chosen the best response.0I don't see any reason why not. It will still be a pointer to memory.

A.Avinash_Goutham
 3 years ago
Best ResponseYou've already chosen the best response.0can u write some code for me?

Chris2332
 3 years ago
Best ResponseYou've already chosen the best response.0void change(char *x) { *x[1]='foo'; return; }

A.Avinash_Goutham
 3 years ago
Best ResponseYou've already chosen the best response.0umm lemme see if that works

A.Avinash_Goutham
 3 years ago
Best ResponseYou've already chosen the best response.0it's not working

Chris2332
 3 years ago
Best ResponseYou've already chosen the best response.0Have you tried void change(char *x) { x[1]='foo'; // < without the * return; }

Chris2332
 3 years ago
Best ResponseYou've already chosen the best response.0by the way... the calling function will be change(foo) not change(&foo)

A.Avinash_Goutham
 3 years ago
Best ResponseYou've already chosen the best response.0that wont worjk either

A.Avinash_Goutham
 3 years ago
Best ResponseYou've already chosen the best response.0no worries got it covered and it's not
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.