What Is Structure Data Type in C?


Scott Campbell

What Is Structure Data Type in C?

In the C programming language, a structure is a user-defined data type that allows you to group different types of variables under a single name. It is a composite data type that combines various elements to create a more complex structure.

Defining a Structure

To define a structure in C, you use the struct keyword followed by the name of the structure and a set of braces. Inside the braces, you define the members or fields of the structure.

struct Person {

  • char name[20];
  • int age;
  • float salary;


In this example, we have defined a structure called Person, which has three members: name, age, and salary. The member names are followed by their respective data types.

Accessing Structure Members

To access the members of a structure, you use the dot operator (.). Here’s an example:

struct Person myPerson;

  • // Assign values to members:
  • // Note: strcpy() is used for string assignment.