Simple Structure Example Program


  • C Structure is a collection of different data types which are grouped together under a common name.
  • Each element in a Structure is called structure member variables.
  • Structure member variables may in same or different datatypes.


struct tag_name {
   type member1;
   type member2;
   /* declare as many members as desired*/

Simple Structure Example Program

/*##Simple Structure Example Program with declaration,assign and Print Values*/
/*##Simple Structure Programs,strcpy Example*/

#include <stdio.h>
#include <string.h>
// Define Strcutre 
struct student 
           int id;
           char name[20];
           int mark;
int main() 
	// Declare Strcutre Variable
	struct student record;
	// Assign Values for Strcutre Memebrs : id,name and mark;
	// Assign Values name using strcpy function;
	strcpy(, "Balan");    
	record.mark = 89;
	// Print Strcutre Memebrs Values
	printf("Student Id   : %d \n",;
	printf("Student Name : %s \n",;
	printf("Student Mark : %d \n", record.mark);
	return 0;

Sample Output:

Student Id   : 1001 
Student Name : Balan 
Student Mark : 89 

C Structure and Union Programs

  1. Simple Structure Example Program