answersLogoWhite

0


Best Answer

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

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

A pointer is a variable that stores a memory address.

int x = 10;

int * p = &x;

Here, an integer, x, is allocated and assigned the value 10, while p is assigned the memory address of that integer. Note that since x is a reference, we can reassign p without creating a memory leak.

p = new int(10);

Here, p is assigned the memory address of a new integer which is assigned the value 10. However, the new integer is not referenced, therefore we cannot reassign p before releasing the integer it points to. If we reassign p without releasing this memory, we'll have a memory leak.

delete( p );

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Pointer is an address (or a variable holding an address). Scale factor is something completely unrelated.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

z=*ptr+2 is the statement is true

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Explain pointer with the help of an example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
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.


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


What is pointer initialization?

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


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;