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

Code Example 1

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 2


struct Student{
long int rollNo;
int age;
char name[50];
int totalMarks;

int main(){

    struct Student s1;
    //accessing members of the struct
    s1.rollNo = 1232234643;
    s1.age = 10;
    char s[]="Jonathan";
    s1.totalMarks = 450;

    printf("RollNumber: %d \nName: %s \nTotal Marks: %d",s1.rollNo,,s1.totalMarks);

return 0;

Code Example 3

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

Code Example 4

#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

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

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

return 0;

Learn ReactJs, React Native from