Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me in C

Status
Not open for further replies.

vrl3

Mechanical
Joined
Nov 4, 2001
Messages
12
Location
IN
In programming language 'C' can we change the value of a variable without touching the variable in any sense?
 
Yes we can
by the use of pointers.
That is what we do by in writing functions
 
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top