求解C语言结构体中字符数组的输入输出问题


#include<stdio.h>

struct Book{
    char title[128];    // 结构成员1
    char author[40];
    float price;
    unsigned int date;
    char publisher[40];
} book;

int main(){
    printf("请输入书名:");
    scanf("%s",book.title);
    printf("请输入作者:");
    scanf("%s",book.author);
    printf("请输入单价:");
    scanf("%f",&book.price);
    printf("请输入出版日期:");
    scanf("%d",&book.date);
    printf("请输入出版社:");
    scanf("%s",book.publisher);
    
    printf("\n\n=====数据录入完毕=====\n\n");

    printf("书本%s的作者是:%s,单价:%.2f,出版日期:%d,出版社是%s",book.title,book.author,book.price,book.date,book.publisher);

    return 0;
}

运行结果:

img

小白求解答,

为什么%s部分的内容用VS Code都没法输出呢?

没看出问题,试试重新编译下。

img


这两个是区别,至今不知道为什么