我只是想说我仍在学习C ++,所以我从关于结构的模块开始,虽然我不了解所有内容,但我认为我的理解是正确的。编译器不断给我的错误是:
错误:“。”之前的预期主表达式 令牌|
#include <iostream>
#include <fstream>
using namespace std;
struct catalog
{
char title[50];
char author[50];
char publisher[30];
int yearpublish;
double price;
};
int main()
{
catalog book;
char again;
fstream fbook;
fbook.open("book.dat", ios::out | ios::binary);
do
{
//Read data about the book
cout << "Enter the following data about a book:\n";
cout << "Title:";
cin.getline (book.title,50);
cout << "Author:";
cin.getline (book.author,50);
cout << "Publisher name:";
cin.getline (book.publisher,30);
cout << "Year publish:";
cin >> book.yearpublish;
cin.ignore();
cout << …Run Code Online (Sandbox Code Playgroud)