#include<stdio.h>
#include<conio.h>
#include<string.h>
struct books
{
char book_name[100];
char book_author[100];
int book_id;
};
void print(int j,book[j])
{
printf("The name of book %d is %s",j,book.book_name);
printf("\nThe author of book %d is %s",j,book.book_author);
printf("\nThe id of book %d is %d",j,book.book_id);
}
int main()
{
int b;
printf("Enter the number of books :");
scanf("%d",&b);
for(int i=1;i<=b;i++)
{
struct books book[i];
printf("Enter the details of book %d /n",i);
printf("Enter the book %d name:",i);
scanf("%s",&book[i].book_name);
printf("\n Enter the author of book %d :",i);
scanf("%s",&book[i].book_author);
printf("\n Enter the id of book %d :",i);
scanf("%d",&book[i].book_id);
}
printf("\n The details of the books you entered are given below:\n");
for(int j=1;j<=b;j++)
{
print(int j,book[j]);
}
getch();
return 0;
}
错误:--> [错误] 'book' 没有在打印函数的这个范围内声明......我怎样才能将结构对象的范围更改为全局?我正在创建一个类似环境的库,并使用结构打印书籍的名称及其详细信息。但是创建的对象超出了范围。它在错误日志中说。帮我解决prblm。