C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 8)
8.
The operator used to get value at address stored in a pointer variable is
Discussion:
33 comments Page 1 of 4.
VASANTHARAJ said:
6 years ago
* is a correct answer. I agree with the given option.
(4)
Rajasekar OMPARR said:
7 years ago
* is known as a de-referencing operator which de-reference the address stored in the pointer. That is fetched the value from that address which pointer is pointing to.
(3)
Antony said:
7 years ago
&&, || operator which operation performed?
(4)
Shraddha said:
9 years ago
I think & is used for address.
(3)
Ravi ku said:
9 years ago
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10;
int *p;
p=&a;
printf("value of A %d",a); //Output-10.
printf("value of A %d",*P); //Output-10.
printf("Address of A %p",a); //Output-fff2.
printf("value of p %d",p); //Output-fff2.
printf("Address of p %d",p); //Output-fff4.
#include<conio.h>
void main()
{
int a=10;
int *p;
p=&a;
printf("value of A %d",a); //Output-10.
printf("value of A %d",*P); //Output-10.
printf("Address of A %p",a); //Output-fff2.
printf("value of p %d",p); //Output-fff2.
printf("Address of p %d",p); //Output-fff4.
(2)
Manmeet said:
9 years ago
If we want to fetch the address of a variable we use & and on the other hand if we want to fetch the value from the address we use *.
(2)
Parag said:
9 years ago
Hello,
I have executing this code and thus it is perfect.
#include <stdio.h>
void main() {
// your code goes here
int x=10;
int *y;
y=&x;
printf("value at Y is %d\n",y);
printf("value at *Y is %d\n",*y);
printf("value at &Y is %d\n",&y);
}
Value at Y is -1076357592.
Value at *Y is 10.
Value at &Y is -1076357588.
--------------------------------------------------------------
So to conclude:
y gives address of x.
*y gives data of x.
&y gives the address of y. The memory which contains the address of x.
I have executing this code and thus it is perfect.
#include <stdio.h>
void main() {
// your code goes here
int x=10;
int *y;
y=&x;
printf("value at Y is %d\n",y);
printf("value at *Y is %d\n",*y);
printf("value at &Y is %d\n",&y);
}
Value at Y is -1076357592.
Value at *Y is 10.
Value at &Y is -1076357588.
--------------------------------------------------------------
So to conclude:
y gives address of x.
*y gives data of x.
&y gives the address of y. The memory which contains the address of x.
(1)
Veer pratap singh said:
1 decade ago
Basically pointer variable is called & operator.
(1)
Swapnali said:
1 decade ago
Pointer is used to store the address of the variable of same type. Ex. char *ptr can be used to store address of char ch..
We use & operator to assign the address of variable to pointer Ex. ptr=&ch;
And we use * operator to get value stored at particular address stored in pointer var. Ex. char chh=*ptr;
We use & operator to assign the address of variable to pointer Ex. ptr=&ch;
And we use * operator to get value stored at particular address stored in pointer var. Ex. char chh=*ptr;
(1)
Harika said:
1 decade ago
Hi, & defines address in memory, * represents the value of pointer.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers