w3resource logo


C Programming Exercises

C Exercises: Show the usage of pointer to structure

Secondary Nav

C Pointer : Exercise-18 with Solution

Write a program in C to show the usage of pointer to structure.
Expected Output :

 John Alter from Court Street

C Code:

#include <stdio.h>
struct EmpAddress
{
char *ename;
char stname[20];
int pincode;
}
employee={"John Alter","Court Street \n",654134},*pt=&employee;

int main()
{
 	printf("\n\n Pointer : Show the usage of pointer to structure :\n"); 
	printf("--------------------------------------------------------\n");
	printf(" %s from %s \n\n",pt->ename,(*pt).stname);
	return 0;
}

Flowchart :

Flowchart: Show the usage of pointer to structure

C Practice online:


#include <stdio.h>
struct EmpAddress
{
char *ename;
char stname[20];
int pincode;
}
employee={"John Alter","Court Street \n",654134},*pt=&employee;

int main()
{
 	printf("\n\n Pointer : Show the usage of pointer to structure :\n"); 
	printf("--------------------------------------------------------\n");
	printf(" %s from %s \n\n",pt->ename,(*pt).stname);
	return 0;
}

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program