Store Data Using Structure

Store data using structure in C, In this program today we learn about storing in C using STRUCT (Structure) through a given Program.

Syntax of Using Structure

typedef struct Studen

{

char sName[20];

int sID;

}

student;

Example of Storing data in Struc

#include <stdio.h>

#include <string.h>
typedef struct Studen
{
char sName[20];
int sID;

} student;

int main()
{
student s;
strcpy(s.sName,"SONY");
s.sID=15;

printf("Student Name : %s\nStudent ID : %d",s.sName,s.sID);

return 0;
}

Student Name : SONY

Student ID :15

Store data using structure in C

Leave a Reply

x