Created
April 25, 2017 15:03
-
-
Save sazid/3341dbdd1165d6b981412457427738e9 to your computer and use it in GitHub Desktop.
Book structure in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
struct Book { | |
char title[100]; | |
char author[100]; | |
int number_of_pages; | |
}; | |
int main() { | |
struct Book let_us_c; | |
// you can ignore this comment block if you don't understand | |
// THIS IS INVALID when we use an array | |
// | | |
// V | |
// let_us_c.title = "Let Us C"; | |
// we need to use strcpy when we use an array | |
strcpy(let_us_c.title, "Let Us C"); | |
strcpy(let_us_c.author, "Yashavant P. Kanetkar"); | |
let_us_c.number_of_pages = 593; | |
printf("Information for let us c book\n"); | |
printf("Title: %s\n", let_us_c.title); | |
printf("Author: %s\n", let_us_c.author); | |
printf("Pages: %d\n", let_us_c.number_of_pages); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment