Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use typedef in C language

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "how to use typedef in C language", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use typedef in C language" article.

You can use typedef to give a new name to a user-defined data type. For example, you can use typedef on the structure to define a new data type name, and then use this new data type to define the structure variable directly, as follows:

# include

# include

Typedef struct Books {

Char title [50]

Char author [50]

Char subject [100]

Int book_id;} Book

Int main () {

Book book; strcpy (book.title, "C tutorial")

Strcpy (book.author, "Runoob")

Strcpy (book.subject, "programming language")

Book.book_id = 12345

Printf ("Book title:% s\ n", book.title)

Printf ("author:% s\ n", book.author)

Printf ("Book categories:% s\ n", book.subject)

Printf ("Book ID:% d\ n", book.book_id)

Return 0

}

When the above code is compiled and executed, it produces the following results:

Book title: C tutorial book author: Runoob book category: programming language book ID: 12345 is about "how to use typedef in C language" this article content, I believe we all have a certain understanding, I hope the editor to share the content is helpful to you, if you want to know more related knowledge content, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report