rsZheng4916 2021-10-01 14:10 采纳率: 60%
浏览 44

求解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都没法输出呢?

  • 写回答

2条回答 默认 最新

  • qzjhjxj 2021-10-01 14:24
    关注

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

    评论

报告相同问题?

问题事件

  • 创建了问题 10月1日