{"id":2772,"date":"2024-05-10T11:24:43","date_gmt":"2024-05-10T11:24:43","guid":{"rendered":"https:\/\/www.skillvertex.com\/blog\/?p=2772"},"modified":"2024-05-10T11:24:43","modified_gmt":"2024-05-10T11:24:43","slug":"c-structures","status":"publish","type":"post","link":"https:\/\/www.skillvertex.com\/blog\/c-structures\/","title":{"rendered":"C Structures"},"content":{"rendered":"\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\" id=\"rank-math-toc\"><p>Table of Contents<\/p><nav><ul><li ><a href=\"#c-structures\">C Structures<\/a><\/li><li ><a href=\"#c-structure-declaration\">C Structure Declaration<\/a><\/li><li ><a href=\"#c-structure-definition\">C Structure Definition<\/a><ul><li ><a href=\"#1-structure-variable-declaration-with-structure-template\">1. Structure Variable Declaration with Structure Template<\/a><\/li><li ><a href=\"#2-structure-variable-declaration-after-structure-template\">2. Structure Variable Declaration after Structure Template<\/a><\/li><\/ul><\/li><li ><a href=\"#access-structure-members\">Access Structure Members<\/a><\/li><li ><a href=\"#initialize-structure-members\">Initialize Structure Members<\/a><\/li><li ><a href=\"#1-initialization-using-assignment-operator\">1. Initialization using Assignment Operator<\/a><\/li><li ><a href=\"#2-initialization-using-initializer-list\">2. Initialization using Initializer List <\/a><\/li><li ><a href=\"#3-initialization-using-a-designated-initializer-list\">3. Initialization using a Designated Initializer List<\/a><\/li><li ><a href=\"#example-of-structure-in-c\">Example of Structure in C<\/a><\/li><li ><a href=\"#typedef-for-structures\">Typedef for Structures<\/a><\/li><li ><a href=\"#nested-structure\">Nested Structure<\/a><\/li><li ><a href=\"#accessing-nested-members\">Accessing Nested Members<\/a><\/li><li ><a href=\"#structure-pointer-in-c\">Structure Pointer in C<\/a><\/li><li ><a href=\"#self-referential-structures\">Self-Referential Structures<\/a><\/li><li ><a href=\"#c-structure-padding-and-packing\">C Structure Padding and Packing<\/a><\/li><li ><a href=\"#bit-fields\">Bit Fields<\/a><\/li><li ><a href=\"#use-of-structure-in-c\">Use of Structure in C<\/a><\/li><li ><a href=\"#limitations-of-c-structures\">Limitations of C Structures<\/a><\/li><li ><a href=\"#faq-c-structures\">FAQ-C Structures<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c-structures\">C Structures<\/h2>\n\n\n\n<p>In C, a structure is a custom data type that enables you to group together items of potentially different data types into a single type. To define a structure in the C programming language, you use the &#8220;struct&#8221; keyword. The individual items contained within the structure are known as its members, and they can be of any valid data type. Structures are commonly used to create complex data structures that represent real-world entities or data with multiple attributes, allowing for more organized and versatile data management in C programs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c-structure-declaration\">C Structure Declaration<\/h2>\n\n\n\n<p>Initially, we have to declare the c structure before using in C program, <\/p>\n\n\n\n<p>In a structure declaration in C, you define the member variables and their data types. To declare a structure, you use the &#8220;struct&#8221; keyword, and the syntax typically follows this pattern:<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct structure_name {\n    data_type member_name1;\n    data_type member_name1;\n    ....\n    ....\n};<\/code><\/pre>\n\n\n\n<p>The syntax provided above is known as the structure template and also, no memory is allocated with it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c-structure-definition\">C Structure Definition<\/h2>\n\n\n\n<p>We have to define structure before applying in the program. Hence, we can define structure in 2 ways:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-structure-variable-declaration-with-structure-template\">1. Structure Variable Declaration with Structure Template<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>struct structure_name {\n    data_type member_name1;\n    data_type member_name1;\n    ....\n    ....\n}variable1, varaible2, ...<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-structure-variable-declaration-after-structure-template\">2. Structure Variable Declaration after Structure Template<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ structure declared beforehand\nstruct structure_name variable1, variable2, .......;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"access-structure-members\">Access Structure Members<\/h2>\n\n\n\n<p>With the help of (.)dot operators, we can access structure members.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>structure_name.member1;\nstrcuture_name.member2;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"initialize-structure-members\">Initialize Structure Members<\/h2>\n\n\n\n<p>We can understand that from the program give below that the structure members cannot be initialized with the declaration. Thus, C program will fail in the compilation.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct Point\n{\n   int x = 0;  \/\/ COMPILER ERROR:  cannot initialize members here\n   int y = 0;  \/\/ COMPILER ERROR:  cannot initialize members here\n};<\/code><\/pre>\n\n\n\n<p>In C, when you declare a data type, no memory is allocated for it until you create variables of that type. Once variables are created, memory is allocated for each instance. Th 3 methods to initialize structure members are the follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Using Assignment Operator.<\/li>\n\n\n\n<li>Using Initializer List.<\/li>\n\n\n\n<li>Using Designated Initializer List.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-initialization-using-assignment-operator\">1. Initialization using Assignment Operator<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>struct structure_name str;\nstr.member1 = value1;\nstr.member2 = value2;\nstr.member3 = value3;\n.\n.\n.<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-initialization-using-initializer-list\">2. Initialization using Initializer List<br><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>struct structure_name str = { value1, value2, value3 };\n<\/code><\/pre>\n\n\n\n<p>Here,  values are provided in sequential order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-initialization-using-a-designated-initializer-list\">3. Initialization using a Designated Initializer List<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>struct structure_name str = { .member1 = value1, .member2 = value2, .member3 = value3 };<\/code><\/pre>\n\n\n\n<p>Structure members will be initialized in any order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"example-of-structure-in-c\">Example of Structure in C<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\n\/\/ C program to illustrate the use of structures \n#include &lt;stdio.h&gt; \n  \n\/\/ declaring structure with name str1 \nstruct str1 { \n    int i; \n    char c; \n    float f; \n    char s&#91;30]; \n}; \n  \n\/\/ declaring structure with name str2 \nstruct str2 { \n    int ii; \n    char cc; \n    float ff; \n} var; \/\/ variable declaration with structure template \n  \n\/\/ Driver code \nint main() \n{ \n    \/\/ variable declaration after structure template \n    \/\/ initialization with initializer list and designated \n    \/\/    initializer list \n    struct str1 var1 = { 1, 'A', 1.00, \"Skill vertex\" }, \n                var2; \n    struct str2 var3 = { .ff = 5.00, .ii = 5, .cc = 'a' }; \n  \n    \/\/ copying structure using assignment operator \n    var2 = var1; \n  \n    printf(\"Struct 1:\\n\\ti = %d, c = %c, f = %f, s = %s\\n\", \n           var1.i, var1.c, var1.f, var1.s); \n    printf(\"Struct 2:\\n\\ti = %d, c = %c, f = %f, s = %s\\n\", \n           var2.i, var2.c, var2.f, var2.s); \n    printf(\"Struct 3\\n\\ti = %d, c = %c, f = %f\\n\", var3.ii, \n           var3.cc, var3.ff); \n  \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Struct 1:\n    i = 1, c = A, f = 1.000000, s = Skillvertex\nStruct 2:\n    i = 1, c = A, f = 1.000000, s = Skillvertex\nStruct 3\n    i = 5, c = a, f = 5.000000<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"typedef-for-structures\">Typedef for Structures<\/h2>\n\n\n\n<p>For structures, using the <code>typedef<\/code> keyword allows you to create a shorter and more convenient name for the structure type. This can help improve code readability and manageability, as you can use the shorter alias throughout your code instead of the longer structure name with the <code>struct<\/code> keyword.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C Program to illustrate the use of typedef with \n\/\/ structures \n#include &lt;stdio.h&gt; \n  \n\/\/ defining structure \nstruct str1 { \n    int a; \n}; \n  \n\/\/ defining new name for str1 \ntypedef struct str1 str1; \n  \n\/\/ another way of using typedef with structures \ntypedef struct str2 { \n    int x; \n} str2; \n  \nint main() \n{ \n    \/\/ creating structure variables using new names \n    str1 var1 = { 20 }; \n    str2 var2 = { 314 }; \n  \n    printf(\"var1.a = %d\\n\", var1.a); \n    printf(\"var2.x = %d\", var2.x); \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var1.a = 20\nvar2.x = 314<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"nested-structure\">Nested Structure<\/h2>\n\n\n\n<p>C structure will enable us to insert from one structure into another as a member. This process is referred as nesting and such structures  are called nested structure . There are 2 methods to do nesting and they are given below:<\/p>\n\n\n\n<p><strong>1. Embedded Structure Nesting<\/strong><\/p>\n\n\n\n<p>Structure is hence declared inside the parent structure.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct parent {\n    int member1;\n    struct member_str member2 {\n        int member_str1;\n        char member_str2;\n        ...\n    }\n    ...\n}<\/code><\/pre>\n\n\n\n<p><strong>2. Separate Structure Nesting<\/strong><\/p>\n\n\n\n<p>In C programming known as &#8220;nesting structures&#8221; or &#8220;structure composition.&#8221; In this approach, you declare one structure within another structure to create a nested or hierarchical data structure.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct member_str {\n    int member_str1;\n    char member_str2;\n    ...\n}\n\nstruct parent {\n    int member1;\n    struct member_str member2;\n    ...\n}<\/code><\/pre>\n\n\n\n<p>The declaration provided below is invalid:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct parent {\n    struct mem a;\n};\n\nstruct mem {\n    int var;\n};<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"accessing-nested-members\">Accessing Nested Members<\/h2>\n\n\n\n<p>Similarly, we can access nested with using .dot operator twice .<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>str_parent.str_child.member;\n<\/code><\/pre>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C Program to illustrate structure nesting along with \n\/\/ forward declaration \n#include &lt;stdio.h&gt; \n  \n\/\/ child structure declaration \nstruct child { \n    int x; \n    char c; \n}; \n  \n\/\/ parent structure declaration \nstruct parent { \n    int a; \n    struct child b; \n}; \n  \n\/\/ driver code \nint main() \n{ { \n    struct parent var1 = { 25, 195, 'A' }; \n  \n    \/\/ accessing and printing nested members \n    printf(\"var1.a = %d\\n\", var1.a); \n    printf(\"var1.b.x = %d\\n\", var1.b.x); \n    printf(\"var1.b.c = %c\", var1.b.c); \n  \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var1.a = 25\nvar1.b.x = 195\nvar1.b.c = A<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"structure-pointer-in-c\">Structure Pointer in C<\/h2>\n\n\n\n<p>In C, you can define pointers that point to structures, just like you would with any other variable. These are typically referred to as &#8220;Structure Pointers.&#8221; Structure pointers allow you to work with and manipulate structures indirectly by pointing to them. To access the members of a structure that&#8217;s pointed to by a structure pointer, you use the arrow (-&gt;) operator.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to illustrate the structure pointer \n#include &lt;stdio.h&gt; \n  \n\/\/ structure declaration \nstruct Point { \n    int x, y; \n}; \n  \nint main() \n{ \n    struct Point str = { 1, 2 }; \n  \n    \/\/ p2 is a pointer to structure p1 \n    struct Point* ptr = &amp;str; \n  \n    \/\/ Accessing structure members using structure pointer \n    printf(\"%d %d\", ptr-&gt;x, ptr-&gt;y); \n  \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1 2<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"self-referential-structures\">Self-Referential Structures<\/h2>\n\n\n\n<p>Self-referential structures, also known as recursive structures, are structures in C that contain references to the same type, essentially creating a circular or nested structure. This is achieved by including a member within the structure that is a pointer to the same structure type. Such structures are often used in scenarios where a hierarchical or nested data structure is needed.<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct structure_name {\n    data_type member1;\n    data_type member2;\n    struct structure_name* str;\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to illustrate the self referential structures \n#include &lt;stdio.h&gt; \n  \n\/\/ structure template \ntypedef struct str { \n    int mem1; \n    int mem2; \n    struct str* next; \n}str; \n  \n\/\/ driver code \nint main() \n{ \n    str var1 = { 1, 2, NULL }; \n    str var2 = { 10, 20, NULL }; \n  \n    \/\/ assigning the address of var2 to var1.next \n    var1.next = &amp;var2; \n  \n    \/\/ pointer to var1 \n    str *ptr1 = &amp;var1; \n  \n    \/\/ accessing var2 members using var1 \n    printf(\"var2.mem1: %d\\nvar2.mem2: %d\", ptr1-&gt;next-&gt;mem1, \n           ptr1-&gt;next-&gt;mem2); \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var2.mem1: 10\nvar2.mem2: 20<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c-structure-padding-and-packing\">C Structure Padding and Packing<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Structure Padding<\/strong>: In C, the size of a structure should technically be the sum of the sizes of its members. However, due to memory alignment and optimization considerations, the actual size of a structure may be larger. Structure padding is the practice of adding empty bytes within the structure to align its data members naturally in memory. The goal is to minimize the CPU read cycles for data retrieval.<\/li>\n\n\n\n<li><strong>Structure Packing<\/strong>: There are situations where you need to pack the structure more tightly, removing the empty bytes to conserve memory. This is particularly important in scenarios where memory efficiency is critical. C provides two common methods for achieving structure packing:\n<ul class=\"wp-block-list\">\n<li>Using <code>#pragma pack(1)<\/code>: This is a compiler-specific directive that sets the packing alignment to 1 byte. It instructs the compiler to minimize padding within the structure.<\/li>\n\n\n\n<li>Using <code>__attribute((packed))__<\/code>: This is another compiler-specific attribute used to achieve structure packing. It&#8217;s common in GCC-based compilers and serves a similar purpose as <code>#pragma pack(1)<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to illustrate structure padding and packing \n#include &lt;stdio.h&gt; \n  \n\/\/ structure with padding \nstruct str1 { \n    char c; \n    int i; \n}; \n  \nstruct str2 { \n    char c; \n    int i; \n} __attribute((packed)) __; \/\/ using structure packing \n  \/\/ driver code \nint main() \n{ \n  \n    printf(\"Size of str1: %d\\n\", sizeof(struct str1)); \n    printf(\"Size of str2: %d\\n\", sizeof(struct str2)); \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Size of str1: 8\nSize of str2: 5<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"bit-fields\">Bit Fields<\/h2>\n\n\n\n<p>Bit Fields&nbsp;are used to specify the length of the structure members in bits. When we know the maximum length of the member, we can use bit fields to specify the size and reduce memory consumption.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct structure_name {\n    data_type member_name: width_of_bit-field;\n};<\/code><\/pre>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/\/ C Program to illustrate bit fields in structures \n#include &lt;stdio.h&gt; \n  \n\/\/ declaring structure for reference \nstruct str1 { \n    int a; \n    char c; \n}; \n  \n\/\/ structure with bit fields \nstruct str2 { \n    int a : 24; \/\/ size of 'a' is 3 bytes = 24 bits \n    char c; \n}; \n  \n\/\/ driver code \nint main() \n{ \n    printf(\"Size of Str1: %d\\nSize of Str2: %d\", \n           sizeof(struct str1), sizeof(struct str2)); \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Size of Str1: 8\nSize of Str2: 4<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"use-of-structure-in-c\">Use of Structure in C<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Custom Data Types<\/strong>: Structures in C can be used to define custom data types that are not present in the language&#8217;s built-in types. This allows you to create complex data types, such as representing dates, times, complex numbers, or other domain-specific data structures.<\/li>\n\n\n\n<li><strong>Data Organization<\/strong>: Structures are often used to organize and group related data into a single data structure. This can be helpful when dealing with a large amount of data that can be logically divided into different fields or attributes.<\/li>\n\n\n\n<li><strong>Data Structures<\/strong>: Structures are essential for creating more complex data structures like trees, linked lists, stacks, and queues. These data structures are the building blocks for many algorithms and applications.<\/li>\n\n\n\n<li><strong>Returning Multiple Values<\/strong>: Structures are a useful way to return multiple values from a function. Instead of returning individual values, you can package related data into a structure and return that structure from a function. This is especially beneficial when a function needs to return several pieces of data that are conceptually related.<\/li>\n<\/ol>\n\n\n\n<p>In essence, structures provide a powerful tool in C for data organization, abstraction, and creating custom data types to represent a wide range of real-world entities and data structures.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"limitations-of-c-structures\">Limitations of C Structures<\/h2>\n\n\n\n<p><strong>Advantages of C Structures:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Packing<\/strong>: Structures provide a way to group data items of different types into a single unit, which is useful for handling logically related data.<\/li>\n<\/ol>\n\n\n\n<p><strong>Limitations of C Structures:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Higher Memory Consumption<\/strong>: Due to structure padding, C structures may consume more memory than expected. This can be inefficient, especially when memory is a concern.<\/li>\n\n\n\n<li><strong>No Data Hiding<\/strong>: C structures do not support data hiding or encapsulation. All members of a structure are typically accessible from any function within the structure&#8217;s scope, which can lead to unintended changes to the structure&#8217;s data.<\/li>\n\n\n\n<li><strong>Functions Inside Structure<\/strong>: C structures do not allow the inclusion of functions within the structure. In object-oriented languages, you can have methods associated with a structure (class), but in C, this is not a feature of structures.<\/li>\n\n\n\n<li><strong>Static Members<\/strong>: C structures cannot have static members. Static members are not supported within the body of a structure.<\/li>\n\n\n\n<li><strong>Construction Creation<\/strong>: C structures do not have constructors. Unlike object-oriented languages, you cannot define constructors for structures in C.<\/li>\n<\/ol>\n\n\n\n<p>It&#8217;s important to be aware of these limitations when working with C structures and to consider whether they align with your specific programming requirements. If encapsulation and associated functions are needed, other programming paradigms, such as object-oriented programming in C++ or other languages, may be more appropriate.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faq-c-structures\">FAQ-C Structures<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1697626768537\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q1. What is a structure in programming?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. Structures, or structs, group related variables into a single entity. Each variable in a struct is called a member. Unlike arrays, structs can hold different data types, like integers, floats, and characters. They&#8217;re used to organize and manage related data efficiently.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1697626780135\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q2. How to create a data structure in C?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. #include &lt;stdio. h><br \/>#include &lt;stdlib. h><br \/>struct Node {<br \/>int data;<br \/>struct Node *next;<br \/>};<br \/>void printList(struct Node *node) {<br \/>while (node != NULL) {<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1697626788416\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q3. What is a structure tag in C?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. A structure can have an optional identifier called a &#8220;tag,&#8221; which provides the name for the structure type. This tag can be used when referencing the structure type in other parts of the program.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><br><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>C Structures In C, a structure is a custom data type that enables you to group together items of potentially different data types into a single type. To define a structure in the C programming language, you use the &#8220;struct&#8221; keyword. The individual items contained within the structure are known as its members, and they &#8230; <a title=\"C Structures\" class=\"read-more\" href=\"https:\/\/www.skillvertex.com\/blog\/c-structures\/\" aria-label=\"More on C Structures\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":5385,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[478],"class_list":["post-2772","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-c-structures","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"_links":{"self":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/2772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/comments?post=2772"}],"version-history":[{"count":8,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/2772\/revisions"}],"predecessor-version":[{"id":10733,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/2772\/revisions\/10733"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media\/5385"}],"wp:attachment":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media?parent=2772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/categories?post=2772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/tags?post=2772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}