Monday, July 27, 2009

Can any body help me in understanding 'pointers' in c language?

Well, a pointer is nothing but a variable which has a special power of accessing other variables through that variable's memory location number.


This number is often called as address.


If address of a variable is specified, then the pointer will act exactly same like the variable.you can use '%26amp;' symbol to get the address of a particular variable.

Can any body help me in understanding 'pointers' in c language?
pointer is a variable that can store address of another variable. for construction of a pointer you have to define it(same as variables) and then you have to assign your variable to the pointer. by pointer of variable you have access to it variable.
Reply:When you create a variable A in c, this variable will be placed somewhere in memory, so it can be accessed by the program.





The amount of memory taken up by this variable is dependent on the type of the variable.





You can then create another variable B that is a pointer to this first variable A. The pointer B will point to the first memory cell taken up by the variable A.





The use of pointers is varied and includes the ability to save space / memory when passing arguments / parameters between functions. The program does not have to copy the data contained in variable A, as it gets a pointer B to the start of the memory occupied by A.
Reply:If you have a piece of data floating somewhere in memory, a pointer is just basically the "address" of where the data is located.





I have attached a link to a tutorial below.

land survey

No comments:

Post a Comment