answersLogoWhite

0

Pointers are data types that hold integer values, those "integer" values are simply addresses of another variables.



Example:

int x = 15; // this is an integer variable with value 15

int* ptr; // this is a pointer to an integer

ptr = &x; // now we assigned the address of x to the pointer ptr

// if you want to access the value of x (15 in this example),
// you should use the deterrence *

// so you can say:
printf("%d", *ptr); // this will print 15

// you can print the value of ptr (which is the address of x) using:

printf("%p", ptr); // this will print an integer, which is the address of x.



==========================================================

More explanation, let's imagine that this is a memory:

-00--01-02-03-04 =====> these are the address of the memory
|--- |--- |---|---|---| =====> values inside the memory


For the example I gave before, let's imagine the following:

-00-01-02--03--04
|---|15|--- | 01 |---|
------x------- ptr


As you can see, x hold the value 15, ptr holds the value 01 which is actually the address of x. Now ptr have a distinct address too, which is 03.

In reality, the address of a memory is longer, and usually represented as hexadecimal values. example 0x002154

You can find more information here:
http://en.wikipedia.org/wiki/Pointers

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Explain pointer to function with example c language?

It isn't a question, sorry.


Explain with help of an an example how FAT different from inode?

explain with help of an example, how FAT is different from inode.


How do you determine the pointer?

What do you mean by 'determine'? Explain, please.


Is a pointer and an English pointer the same?

Pointers come in different breeds. For example: German Short Haired Pointer and English Pointer.


What is pointer operator?

For example: [] * -> + - ++ -- = += -= & == < <= > >= !


What is triple pointer?

Example: int x; -- integer int *px= &x; -- pointer to integer int **ppx= &px; -- pointer to pointer to integer int ***pppx= &ppx; -- pointer to pointer to pointer to integer


What is the difference between the Constant pointer and pointer constant and explain it with an example?

Pointer to constant *ptr=10 statement is invalid in pointer to constant i.e assigning value is illegal ptr++ statement is valid in pointer to constant. pointer can be incremented and decremented, Pointer is pointing to constant data object. Declaration: const int *ptr; Constant pointers: *ptr= 10 is absolutely valid in constant pointers i.e assigning value is perfectly legal ptr+++ statement is invalid in constant pointers. pointer can not be incremented or decremented. Declaration; int *const ptr;


Pointer to pointer in c?

Usable. A prominent example is param argv of function main.


What is pointer initialization?

Assigning an initial value to a pointer variable. Example: int *p= NULL;


Explain a program for this pointer in cpp?

Go to the link. You will got use of "this" keywork with simple explanation and example. http://cpp.codenewbie.com/articles/cpp/1527/Keyword_this-Page_5.html


Can a pointer be considered a variable?

You can declare pointer-variables, if that's what you mean. Example: char *sample = "Sample";


C program pointers to pointers examples?

Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;