Professional Documents
Culture Documents
Structure
C prog
Pointer to Structure Pointer to structure holds the add of the entire structure.
It is used to create complex data structures such as linked lists, trees, graphs
and so on.
The members of the structure can be accessed using a special operator called
as an arrow operator ( ->).
Declaration Following is the declaration for pointers to structures in C programming −
example
#include<stdio.h>
struct student
{ printf ("details of the student are");
int sno;
char sname[30];
printf ("Number = %d", st ->sno);
float marks;
};
Int main ( ) printf ("name = %s ", st->sname);
{
struct student s; printf ("marks =%f ", st ->marks);
struct student *st;
st = &s;
printf("enter sno, sname, marks:"); Return 0;
}
scanf ("%d%s%f", & s.sno, s.sname, &s. marks);
Output
Let us run the above program that will produce the following result −
int main()
{
int main()
{
void (*fun_ptr)(int) = fun; // & removed
fun_ptr(10);
return 0;
}