C语言结构体完整解析(三):直接给结构体赋初值

tech2022-08-18  122

源码:

// // Created by kangs on 2020/9/2. // #include <stdio.h> struct Books { char title[50]; char author[50]; char subject[100]; int book_id; } book = {"C 语言", "NOWCODER", "编程语言", 123456}; 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: NOWCODER subject: 编程语言 book_id: 123456 Process finished with exit code 0
最新回复(0)