answersLogoWhite

0


Best Answer

Yes, two different pointer variables may point to the same memory location. Two issues, though... If your code thinks the two pointers represent two different allocations of memory, then you risk deallocating one and not realizing that the other is now invalid. You need to make sure that your compiler optimization settings for volatility are correct, otherwise the compiler could generate code that does not always work correctly.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can two different pointer variables point to the same memory location?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is poiner value in c?

In c a pointer is a variable that points to or references a memory location in which data is stored. Each memory cell in the computer has an address that can be used to access that location so a pointer variable points to a memory location we can access and change the contents of this memory location via the pointer. Pointer declaration A pointer is a variable that contains the memory location of another variable. The syntax is as shown below. You start by specifying the type of data stored in the location identified by the pointer. The asterisk tells the compiler that you are creating a pointer variable. Finally you give the name of the variable. type * variable name Example: int *ptr; float *string;


What is a use of dereferencing operator?

A pointer variable contains the address to some memory location. "Dereferencing" the pointer means getting the value stored at that memory location.


Passing an array name to a pointer assigns the first memory location of the array to the pointer variable?

Yes, passing an array name to a pointer assigns the first memory location of the array to the pointer variable. An array name is the same as a pointer to the first location of the array, with the exception that an array name is a r-value, while a pointer is an l-value.


How many pointers can be used in a c program?

Answergenerally we use simple pointer, void pointer,null pointer, structure pointer. Answerzero or more (unlimited).


What is an address in C plus plus programming?

An address in C or C++ is the location in memory of an object or function. An address is the contents of a pointer, as opposed to the contents of the memory location pointed to by the pointer.

Related questions

What are pointer to pointer?

A pointer only holds an address information (location) in the memory. if a pointer holds points another pointer then it is a pointer to an other pointer. Pointer holds an address in the memory so in that address there is an other location information that shows another location.


What is pointer why you use pointer?

Pointer is a variable that stores the address of another variable. Since pointer is also akind of variable, thus pointer itself will be stored at a different memory location.


What is poiner value in c?

In c a pointer is a variable that points to or references a memory location in which data is stored. Each memory cell in the computer has an address that can be used to access that location so a pointer variable points to a memory location we can access and change the contents of this memory location via the pointer. Pointer declaration A pointer is a variable that contains the memory location of another variable. The syntax is as shown below. You start by specifying the type of data stored in the location identified by the pointer. The asterisk tells the compiler that you are creating a pointer variable. Finally you give the name of the variable. type * variable name Example: int *ptr; float *string;


What is a use of dereferencing operator?

A pointer variable contains the address to some memory location. "Dereferencing" the pointer means getting the value stored at that memory location.


What is pointer to a structure?

A pointer is a variable that holds address information. For example, in C++, say you have a Car class and another class that can access Car. Then, declaring Car *car1 =new Car() creates a pointer to a Car object.. The variable "car1" holds an address location.


WHAT IS POINTER TO POINTER IN C POINTER?

Pointer in C is Memory Reference. It stores memory address of any variable, constant, function or something you later use in your programming. Pointer basically used to ease the referencing of variables and others or in polymorphism and inheritance.


Passing an array name to a pointer assigns the first memory location of the array to the pointer variable?

Yes, passing an array name to a pointer assigns the first memory location of the array to the pointer variable. An array name is the same as a pointer to the first location of the array, with the exception that an array name is a r-value, while a pointer is an l-value.


What is an address in C plus plus programming?

An address in C or C++ is the location in memory of an object or function. An address is the contents of a pointer, as opposed to the contents of the memory location pointed to by the pointer.


How many pointers can be used in a c program?

Answergenerally we use simple pointer, void pointer,null pointer, structure pointer. Answerzero or more (unlimited).


How do pointer work in c program?

Pointer can be defined as variable that is used to store memory address , usually the location another variable in memory. Pointers provide a means through which memory location of a variable can be directly accessed.


What is a ponters in c-programming?

with the help of pointers we able to store the memory location of any variable. In c the pointer variable is use to store the memory location of any variable. The pointer variable is define as a simple variable but in pointer variable use a special "*" character at the left most side of name of pointer variable. If any variable name have * it means it is a pointer variable it hold the memory location of variable.


What is pointer in computer language?

A pointer is a variable, much like any other variable, but one that contains a value that is interpreted as a memory address. The variable is said to "point" at that address. In 32-bit systems, the variable is 4-bytes in length. In 64-bit systems it is 8-bytes in length. If the value is zero the pointer is said to be NULL -- it doesn't point anywhere. Any other value denotes the pointer is pointing at a memory location. The type of pointer determines how it treats the memory it is pointing at. For instance, an int pointer treats the memory location as if it contained an integer -- regardless of its actual type. We can access the memory location itself by using the indirection operator (-->). Providing the pointer is the correct type for the object stored in that memory, we can work with the object just as if we had a direct reference to the object.Pointers are extremely powerful. By altering the value stored in the pointer, the pointer can be made to point at any memory location -- including other pointer variables, objects and values, even functions. Pointers also allow us to pass memory locations to functions, in much the same way as we can pass values to functions. And like all other primitives, we can use simple mathematics to adjust a pointer's value, such as increment and decrement, allowing the pointer to "roam" through a series of memory locations.