C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 5)
5.
If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?
Discussion:
60 comments Page 4 of 6.
Vaishali said:
1 decade ago
Thanks Pavan Sharath for clearify Structure.
Joshi said:
1 decade ago
To access data members of a structure we have to create a variable if thar variable if normal variable then we will use "."(dot) operator if thar is pointer variable then we will use "->"arrow operator.
example:
#include<stdio.h>
struct st
{
int x;
};
main()
{
struct st var1; creating normal variable
struct st *var2; creating pointer variable
//accessing data members of structure normal variable
scanf("%d",var1.x);
printf("%d",var1.x);
//accessing data membres of structure pointer vairables
scanf("%d",var1->x);
printf("%d",var1->x);
}
example:
#include<stdio.h>
struct st
{
int x;
};
main()
{
struct st var1; creating normal variable
struct st *var2; creating pointer variable
//accessing data members of structure normal variable
scanf("%d",var1.x);
printf("%d",var1.x);
//accessing data membres of structure pointer vairables
scanf("%d",var1->x);
printf("%d",var1->x);
}
Vishwanath sampath said:
1 decade ago
Pointer is a address of value. Then will find the address if you are submit that values.
Supriya said:
1 decade ago
Can any one help me by telling how execute programs on India bix (c) through online compiler by giving my own input at command prompt.
Dhanalakshmi said:
1 decade ago
An individual structure member can be accessed in terms of its corresponding pointer variable by writing.
ptr -> member.
ptr -> member.
Ronit said:
1 decade ago
Can anybody say what is the actual difference, when we acces the member of struct by using "." operator & "->" operator ?
Saurabh said:
1 decade ago
Pointer variable can also be accessible by two type
Type:1
(*a).p//if a is the pointer variable of p.
type:2
It can also be written same as..
a->p;
Type:1
(*a).p//if a is the pointer variable of p.
type:2
It can also be written same as..
a->p;
Ameena said:
1 decade ago
Pointer definition: it can store the & of the another variable, so we are using pointer, using arrow "->", operator, ". ", dot operator are used in pointer.
Haarika said:
1 decade ago
What is enum? in what situation we use it? can anybody help me out? please.
Bhargavi said:
1 decade ago
enum is a one of the userdefined datatype,and it defines the list of keywords.
Ex:
enum rainbow
{
1.Red
2.Orange
3.Yellow
4.Green
5.Blue
6.Indigo
7.Violet
} ;
Ex:
enum rainbow
{
1.Red
2.Orange
3.Yellow
4.Green
5.Blue
6.Indigo
7.Violet
} ;
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers