Structure

From ElectroDragon Wiki
Revision as of 13:34, 20 November 2019 by Chao (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

C 数组允许定义可存储相同类型数据项的变量,结构是 C 编程中另一种用户自定义的可用的数据类型,它允许您存储不同类型的数据项。


结构用于表示一条记录,假设您想要跟踪图书馆中书本的动态,您可能需要跟踪每本书的下列属性:

  • Title
  • Author
  • Subject
  • Book ID
struct tag { 
    member-list
    member-list 
    member-list  
    ...
} variable-list ;



struct Books
{
   char  title[50];
   char  author[50];
   char  subject[100];
   int   book_id;
} book;