Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct Book {
  5. char title[100];
  6. char author[100];
  7. int number_of_pages;
  8. };
  9.  
  10. int main() {
  11. struct Book let_us_c;
  12.  
  13. // you can ignore this comment block if you don't understand
  14. // THIS IS INVALID when we use an array
  15. // |
  16. // V
  17. // let_us_c.title = "Let Us C";
  18.  
  19. // we need to use strcpy when we use an array
  20. strcpy(let_us_c.title, "Let Us C");
  21. strcpy(let_us_c.author, "Yashavant P. Kanetkar");
  22. let_us_c.number_of_pages = 593;
  23.  
  24. printf("Information for let us c book\n");
  25. printf("Title: %s\n", let_us_c.title);
  26. printf("Author: %s\n", let_us_c.author);
  27. printf("Pages: %d\n", let_us_c.number_of_pages);
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement