Program to create a structure and access it in C

#include <stdio.h>
#include <string.h>
struct books{
       char title[20];
       char publisher[25];
       char author[20];
       int no_of_pages;
       float cost;
int main()
  struct books book1;
  strcpy(book1.title, "C tutorials");
  strcpy(book1.publisher, "some publisher");
  strcpy(, "some author");
  printf("Book Title: %sn",book1.title);
  printf("Book Publisher: %sn",book1.publisher);
  printf("Book Author: %sn",;
  printf("No. of Pages: %dn",book1.no_of_pages);
  printf("Cost: %fn",book1.cost);
  return 0;

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.