C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 7)
7.
A pointer is
Discussion:
33 comments Page 1 of 4.
Mukesh Kr Siddhwan said:
10 years ago
Pointer is a specific type of variable that can be used to store the address of other variable. It is always denoted by '*' operator.
Some Features of pointer:
1. Pointer save the memory space.
2. Execution time with pointer is faster because data is manipulated with the address. i.e., direct access to memory location.
Pointer declaration:
Data type *pointer name;.
For example:
void main()
int a=100;
int *p;
p=&a;
In above example 'a' is the integer type of variable and 100 ia the value of that variable. *p is the pointer name. Suppose 4066 is the address of variable 'a'.
In above example p=&a;-in this code pointer p can be use to store the address of variable 'a', means the value of pointer p is 4066 (that is the address of variable 'a').
Some Features of pointer:
1. Pointer save the memory space.
2. Execution time with pointer is faster because data is manipulated with the address. i.e., direct access to memory location.
Pointer declaration:
Data type *pointer name;.
For example:
void main()
int a=100;
int *p;
p=&a;
In above example 'a' is the integer type of variable and 100 ia the value of that variable. *p is the pointer name. Suppose 4066 is the address of variable 'a'.
In above example p=&a;-in this code pointer p can be use to store the address of variable 'a', means the value of pointer p is 4066 (that is the address of variable 'a').
(1)
Michae Trussler said:
1 decade ago
The answer can be summarized as follows...
[A] A keyword used to create variables -> Wrong. A pointer is NOT a keyword.
[B]. A variable that stores address of an instruction -> Wrong. Though a pointer may hold the address of an instruction (i.e. function pointer), it is no required to
[C]. A variable that stores address of other variable -> Correct. A pointer is a variable that stores the address of any other variable be it a value or another address.
[D]. All of the above -> Wrong as A and B are incorrect.
[A] A keyword used to create variables -> Wrong. A pointer is NOT a keyword.
[B]. A variable that stores address of an instruction -> Wrong. Though a pointer may hold the address of an instruction (i.e. function pointer), it is no required to
[C]. A variable that stores address of other variable -> Correct. A pointer is a variable that stores the address of any other variable be it a value or another address.
[D]. All of the above -> Wrong as A and B are incorrect.
Jim said:
1 decade ago
Your answer is confusing because pointers can ALSO store things that are not variables.
A variable is something that has a type, value, and a symbolic name.
- Pointer to a string constant. char *p = "Hello";
Note that a string constant does not have a name. This is not a pointer to a variable.
- Pointer to dynamic memory. int *p = (int *) malloc(10);
Note that the memory dynamically allocated is mutable but it is not a variable because it has no name.
What about a pointer to a function?
A variable is something that has a type, value, and a symbolic name.
- Pointer to a string constant. char *p = "Hello";
Note that a string constant does not have a name. This is not a pointer to a variable.
- Pointer to dynamic memory. int *p = (int *) malloc(10);
Note that the memory dynamically allocated is mutable but it is not a variable because it has no name.
What about a pointer to a function?
Rishikesh Agrawani said:
1 decade ago
Hello friends, I just want to discuss few points about the pointer:
(1) A pointer is a variable of specific type, which is capable of holding the address of another variable of the same type.
(2) It is most powerful concept of c/c++, which allows us to manipulate the contents of memory by their addresses.
(3) You can sort the set of strings by using only single double pointer variable in your source program, try to do it, if you never tried. It will help you to have the good knowledge of pointer.
(1) A pointer is a variable of specific type, which is capable of holding the address of another variable of the same type.
(2) It is most powerful concept of c/c++, which allows us to manipulate the contents of memory by their addresses.
(3) You can sort the set of strings by using only single double pointer variable in your source program, try to do it, if you never tried. It will help you to have the good knowledge of pointer.
Rishikesh Agrawani said:
10 years ago
A pointer is a variable of specific type, whose value is address of another variable of its type. The variable can be of any built-in type or any user defined type.
We should have the good knowledge of pointers as it provides a good way of handling dynamic data structures like linked list, stack, queue etc. We use indirection operator (*) in front of variable name for declaring pointer variable.
Eg: int *iptr; char *cptr;
We should have the good knowledge of pointers as it provides a good way of handling dynamic data structures like linked list, stack, queue etc. We use indirection operator (*) in front of variable name for declaring pointer variable.
Eg: int *iptr; char *cptr;
Raju Naidu said:
1 decade ago
Normal variable means it stores the values directly. But if you want to change those values without touching those variables we are using pointers.
Pointer is a one type of variable it holds the address of the variable.
int a=5; // suppose a variable address is 100
int *p;
p=&a;// here p(pointer variable)holdes the address of the a variable.
Pointer is a one type of variable it holds the address of the variable.
int a=5; // suppose a variable address is 100
int *p;
p=&a;// here p(pointer variable)holdes the address of the a variable.
Manmeet said:
1 decade ago
The correct definition of a pointer is:
Pointer is a variable that stores logical address of an another variable.
We should always specify what type of address we are talking about.
As there are two types of addresses that are:
1: Physical addresses.
2: Logical addresses.
Pointer is a variable that stores logical address of an another variable.
We should always specify what type of address we are talking about.
As there are two types of addresses that are:
1: Physical addresses.
2: Logical addresses.
Shashank said:
1 decade ago
Pointer is a generic term which means "pointing to something".We can use pointer to store address of any variable or any function (Function pointer).
"Program Counter also known as instruction pointer (IP) in Intel x86 holds the address of instruction."
"Program Counter also known as instruction pointer (IP) in Intel x86 holds the address of instruction."
Suryaiiit said:
1 decade ago
pointer is also variable it stores the addres of another variable and also stores addres of itself.
//
(i) int i,*p;
p=&i;
(ii) int *p;
p=&p;
//
both cases are possible i hope now u understand wt a pointer is
//
(i) int i,*p;
p=&i;
(ii) int *p;
p=&p;
//
both cases are possible i hope now u understand wt a pointer is
Mary gold said:
1 decade ago
Pointer is not a variable because variable is used to store the values but pointer is used to store the address of variable.
So pointer is a operator which is used to store the address of another variable.
So pointer is a operator which is used to store the address of another variable.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers