Here's the question you clicked on:

55 members online
  • 0 replying
  • 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?

  • This Question is Closed
  1. Chris2332
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  2. A.Avinash_Goutham
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    can u write some code for me?

  3. Chris2332
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  4. A.Avinash_Goutham
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    umm lemme see if that works

  5. A.Avinash_Goutham
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it's not working

  6. Chris2332
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    and the error is?

  7. Chris2332
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  8. Chris2332
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  9. A.Avinash_Goutham
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ooo

  10. A.Avinash_Goutham
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    that wont worjk either

  11. A.Avinash_Goutham
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    no worries got it covered and it's not

  12. A.Avinash_Goutham
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  13. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy