Lokang 

C and MySQL

Structures (structs)

In C, a structure is a user-defined data type that can hold a collection of variables of different data types. Structures are used to represent complex data types, such as records or objects, and they allow you to group related data together and access it using a single variable.

Here is an example of defining a structure in C:

#include <stdio.h>
struct point {
   int x;
   int y;
};
int main()
{
   struct point p = {0, 0};
   printf("Point: (%d, %d)\n", p.x, p.y);
   return 0;
}

In this example, we have defined a structure called point that has two integer fields: x and y. The structure is defined using the struct keyword, followed by the structure name and the list of fields in curly braces.

To create a variable of the point structure type, we use the struct keyword followed by the structure name and a variable name. In this example, we have created a variable p of the point structure type and initialized it with the values 0 and 0.

To access the fields of a structure, you can use the . operator followed by the field name. In this example, we have used the printf function to print the values of the x and y fields of the p structure.

Structures are a useful tool for representing complex data types and for organizing and accessing data in a structured way. They are often used in conjunction with pointers to create linked lists, trees, and other data structures.