C++ 函数中的声明语法错误

C++ 函数中的声明语法错误,c++,syntax,declaration,turbo-c++,C++,Syntax,Declaration,Turbo C++,请帮我解决这个问题,我在学校也输入了代码,即使在那里它显示了声明语法错误。-我想不出来。当你刚刚开始学习编码的时候,它是如此令人沮丧 无效问题错误:声明语法错误 无效显示错误:非法使用指针 如果发现我有任何愚蠢之处,请道歉 #include <iostream.h> #include <conio.h> #include <stdio.h> #include <string.h> class book { char bookname[20];

请帮我解决这个问题,我在学校也输入了代码,即使在那里它显示了声明语法错误。-我想不出来。当你刚刚开始学习编码的时候,它是如此令人沮丧

无效问题错误:声明语法错误 无效显示错误:非法使用指针

如果发现我有任何愚蠢之处,请道歉

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>


class book
{
char bookname[20];
char isbn[20];
char author[20];
char category[20];
float price;
int noc;

public:

void accept()
{

cout<<"Enter book name :- \n";
gets(bookname);
cout<<"Enter isbn no of the book:- \n";
gets(isbn);
cout<<"Enter authour name:- \n";
gets(author);
cout<<"Enter category of book:- \n";
gets(category);
cout<<"Enter price of the book :- \n";
cin>>price;
cout<<"Enter no of copies of book available in the library :- \n";
cin>>noc;
}

void display()
{
puts(bookname)<<endl;
puts(isbn)<<endl;
puts(author)<<endl;
puts(category)<<endl;
cout<<price<<endl;
cout<<noc<<endl;
}

}b[5];

int main()
{
for(int i=0;i<5;++i)
{
b[i].accept();
}

void issue()
{
int flag=0;
char booksearch[20];
cout<<"Enter name of book member wants to issue :- \n"
gets(booksearch);
  for(i=0;i<5;++i)
  {
      flag=strcmp(booksearch,b[i].bookname)
  }

}

 if(flag==1)
 {
   b[i].display();
   b[i].issue();
 }
 getch();
 return 0;
 }
#包括
#包括
#包括
#包括
课堂用书
{
字符书名[20];
char-isbn[20];
char作者[20];
炭类[20];
浮动价格;
国际国家奥委会;
公众:
无效接受()
{
库特
  • flag=strcmp(searchbook,b[I].bookname)
    行后添加分号
  • 声明
    标志
    搜索簿
    b
    (如果尚未声明)
  • 在你的活动之前,一定要包括

  • 您的代码有许多错误:

  • strcmp
    调用后缺少分号:
  • strcmp
    当存在匹配时返回0,而不是1,并且您可能会在循环的下一次迭代中覆盖标志
  • <>你对<代码>发行< <代码>的定义在<>代码>主< /代码>,
  • 您正在混合使用c风格的get和c++风格的操作符>>

  • 您正在混合-糟糕-c样式的puts和运算符。您可以更具体一些..并发布更多的代码欢迎来到StackOverflow!请花时间仔细检查。特别是您应该在问题中包含完整的复制粘贴错误。您使用的是纯文本编辑器还是文字处理器?
    #include <iostream>
    #include <string>
    #include <array>
    #include <limits>
    
    using namespace std;
    
    class book
    {
        std::string bookname;
        std::string isbn;
        std::string author;
        std::string category;
        float price;
        int noc;
    
    public:
        const std::string& getBookname() const { return bookname; }
        const std::string& getISBN() const { return isbn; }
        const std::string& getAuthor() const { return author; }
        const std::string& getCategory() const { return category; }
        float getPrice() const { return price; }
        float getNoC() const { return noc; }
    
        void accept()
        {
            cout<<"Enter book name :- \n";
            std::getline(std::cin, bookname);
            cout<<"Enter isbn no of the book:- \n";
            std::getline(std::cin, isbn);
            cout<<"Enter authour name:- \n";
            std::getline(std::cin, author);
            cout<<"Enter category of book:- \n";
            std::getline(std::cin, category);
            cout<<"Enter price of the book :- \n";
            std::cin>>price;
            cout<<"Enter no of copies of book available in the library :- \n";
            std::cin>>noc;
            std::cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
        }
    
        void display()
        {
            std::cout<<bookname<<std::endl;
            std::cout<<isbn<<std::endl;
            std::cout<<author<<std::endl;
            std::cout<<category<<std::endl;
            std::cout<<price<<std::endl;
            std::cout<<noc<<std::endl;
        }
    
        void issue()
        {
        }
    };
    
    int main()
    {
        std::array<book, 5> b;
        for(int i=0;i<b.size();++i)
        {
            b[i].accept();
        }
    
        std::string booksearch;
        std::cout<<"Enter name of book member wants to issue :- \n";
        std::getline(cin, booksearch);
        std::cout<<"Searching for: " << booksearch << "\n";
        for(int i=0;i<b.size();++i)
        {
            if (b[i].getBookname() == booksearch)
            {
                b[i].display();
                b[i].issue();
                break;
            }
        }
    
        std::string dummy;
        std::cout << "Hit return:";
        std::getline(std::cin, dummy);
    
        return 0;
    }