Check out example codes for "c struct". It will help you in understanding the concepts better.

Code Example 1

struct struct1 {
  int a;
  char b;
}
typedef struct struct2 {
  int a;
  char b;
} name;

void main()
{
  struct struct1 var1;
  name			 var2;
  
  var1.a = 10;
  var2.b = 'c';
}

Code Example 2

struct Point 
{ 
   int x, y; 
};  
   // Never forget the semicolon after the struct definition.
int main() 
{ 
   // A valid initialization. member x gets value 0 and y 
   // gets value 1.  The order of declaration is followed. 
   struct Point p1 = {0, 1};  
}

Code Example 3

#include <stdio.h>
#include <stdlib.h>

struct book{ //this is like making a datatype of type book
    //these are the fields
  	char name[50];
    char author[50];
    char ISBN[11];
};

int main(){
    struct book book1; //making an instance of book called book1
    /*
    normally to store integers in a struct we can do something like
    book1.number_of_pages = 22; which is correct
    however with character arrays we need to use the strcpy
    function
    */

    strcpy(book1.name, "james and the giant tatti");
    strcpy(book1.author, "Krishan Grewal");
    strcpy(book1.ISBN, "12345678987");

    printf("book name: %s\n", book1.name);
  	printf("book author: %s\n", book1.author);
  	printf("book ISBN: %s\n", book1.ISBN);

return 0;
}

Code Example 4

struct listitem {
    int val;
    char * def;
    struct listitem * next;
};

Code Example 5

#include <stdio.h>
/*
hacer un programa para registrar los datos de tres libros como:
    título, autor, año y color del libro.
El color se deberá hacer mediante una enumeración y sólo habrá rojo, verde y azul.
*/
enum Color {rojo, verde, azul};

struct Libro{
	int paginas;
	const char* autor;
	const char* titulo;
	enum Color color;
};

void datosLibro(struct Libro *libro){
	libro->paginas = 200;
	libro->autor = "Cervantes";
	libro->titulo = "El Quijote";
	libro->color = verde;
/*
struct student {
   char name[50];
   int age;
};

printf("Enter name: ");
scanf("%[^\n]%*c", s1.name);
*/
}

void mostrarDatos(struct Libro *libro){

	printf("paginas: %d\n", libro->paginas);
	printf("autor: %s\n", libro->autor);
	printf("titulo: %s\n", libro->titulo);

	switch (libro->color) {
		case rojo:
			printf("Color: rojo\n");
			break;
		case verde:
			printf("Color: verde\n");
			break;
		case azul:
			printf("Color: azul\n");
			break;
	}
}

int main(){
	struct Libro libro1;

	datosLibro(&libro1);
	mostrarDatos(&libro1);

	return 0;
}

Learn ReactJs, React Native from akashmittal.com