Dec 7, 2001 #1 vrl3 Mechanical Nov 4, 2001 12 0 0 IN In programming language 'C' can we change the value of a variable without touching the variable in any sense?
In programming language 'C' can we change the value of a variable without touching the variable in any sense?
Dec 7, 2001 #2 veejai Computer Oct 15, 2001 1 0 0 IN Yes we can by the use of pointers. That is what we do by in writing functions Upvote 0 Downvote
Dec 26, 2001 #3 umn Electrical Jun 8, 1999 50 0 0 US A bit more detail with an example: //Declare an integer variable val and initialize it int val = 0; //Get the address of the variable 'val int *pVal = &val; //Change the value of the variable val without //touching the variable name 'val' *pVal = 10; // Now, you've changed the value of val Narayanan UM umn@ieee.org asaan@lycos.com Upvote 0 Downvote
A bit more detail with an example: //Declare an integer variable val and initialize it int val = 0; //Get the address of the variable 'val int *pVal = &val; //Change the value of the variable val without //touching the variable name 'val' *pVal = 10; // Now, you've changed the value of val Narayanan UM umn@ieee.org asaan@lycos.com