输入到第三个提示错误输入不了是怎么回事,请高手指点
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>
#define W 3
typedef struct Book
{
char title;
char author;
float price;
unsigned int date;
char publisher;
}Book;
int main(void)
{
Book Book_one;
Book* Pt;
Pt = &Book_one;
//Book_one = &Book;
int i = 0;
for (i = 0;i < W;i++)
{
printf("请输入书名: ");
scanf("%s",*Pt->title);
printf("请输入作者: ");
scanf("%s",Book_one.author);
printf("请输入售价: ");
scanf("%f",Book_one.price);
printf("请输入出版日期: ");
scanf("%d",Book_one.date);
printf("请输入出版社: ");
scanf("%s",Book_one.publisher);
}
printf("\n============数据录入完毕===========\n");
for (i = 0;i < W;i++)
{
printf("书名:%s\n ", (*Pt).title);
printf("作者:%s\n ", Book_one.author);
printf("售价:%f\n ", Book_one.price);
printf("出版日期:%d\n ", Book_one.date);
printf("出版社:%s\n ", Book_one.publisher);
}
return 0;
} 本来想搞个复习的,结果出个这样情况,,,,不要看下面的结构体指针,那是练习的,就是正常格式下也不行
我发现了两个问题:①PT是指针,Book_one是数组,赋值时不需要加&
②进入for循环时Book_one应该是Book_one
页:
[1]