Define a simplest struct : Struct Define « Structure « C / ANSI-C






Define a simplest struct

#include <stdio.h>

int main(void)
{
  struct {
    int a;
    int b;
  } x, y; 

  x.a = 10;

  y = x;  /* assign one structure to another */

  printf("%d", y.a);

  return 0;
}


  

           
       








Related examples in the same category

1.Using a structure representing a length
2.Using a structure representing a person's name
3.Using a structure to record the count of occurrences of a word
4.How to use struct
5.Exercising the horse: Structure declaration
6.Pointing out the horses: allocate memory for struct
7.Define and use a struct