Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • 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
Nov 4, 2001
12
In programming language 'C' can we change the value of a variable without touching the variable in any sense?
 
Replies continue below

Recommended for you

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