小编use*_*721的帖子

C ++错误-预期在'。'之前的主表达式 令牌| 在结构上

我只是想说我仍在学习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)

c++ structure

2
推荐指数
1
解决办法
768
查看次数

标签 统计

c++ ×1

structure ×1