|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct BOOK
{
char name[10];
char author[8];
float price;
char publisher[20];
};
void* Input(struct BOOK* book);
void* Input(struct BOOK* book)
{
ptintf("请输入书的名字\n");
scanf("%s",book->name);
ptintf("请输入书的作者\n");
scanf("%s",book->author);
ptintf("请输入书的价格\n");
scanf("%f",&book->price);
ptintf("请输入书的出版社\n");
scanf("%s",book->publisher);
}
void* Print(struct BOOK* book);
void* Print(struct BOOK* book)
{
printf("书的名字:%s\n",book->name);
printf("书的作者:%s\n",book->author);
printf("书的价格:%s\n",book->price);
printf("书的出版社:%s\n",book->publisher);
}
int main()
{
int i;
printf("打算输入几本书:\n");
scanf("%d",&i);
struct BOOK *ptr=NULL;
ptr=(struct BOOK *)malloc(i*sizeof(struct BOOK ));
int m;
for(m=0;m<i;m++)
{
Input(ptr+m);
Print(ptr+m);
}
return 0;
}
本帖最后由 桃花飞舞 于 2023-3-1 22:30 编辑
void* Input(struct BOOK* book) 函数里面的printf()写错了 这么清楚的错误提示细心点
|
|