「C言語」struct構造体の使い方

サンプルコード

#include <stdio.h>

struct Books
{
   char  title[50];
   char  author[50];
   char  subject[100];
   int   book_id;
} book = {"C言語入門", "PHP入門", "Java言語入門", 667788};
 
int main()
{
    printf("title : %s\nauthor: %s\nsubject: %s\nbook_id: %d\n", book.title, book.author, book.subject, book.book_id);
}

実行結果:
title : C言語入門
author: PHP入門
subject: Java言語入門
book_id: 667788

C++

Posted by arkgame