视觉C 编译错误

Visual C++ Compile Error

本文关键字:错误 编译 视觉      更新时间:2023-10-16

我有时间在这个程序上。我正在使用一个数据文件,该数据文件有12行,每月一条,一个月后的数字位置为2个。示例:

1月9日11

我基本上将月份的名称删除到前3个字母,将它们转换为大写,并引入数字(整数)与它们合作。我正在使用vs 2012,并且一旦我输入" infile>> student.numboys"行,我就会遇到这个喧闹的编译错误:采用" int [2]'类型的右手操作数(或没有可接受的转换)"

自然,我什至没有开始使用数据文件。我已经去了几个小时,所以我要看一段时间了。如果我缺少明显的明显的东西,请对我柔软。

    #include <iostream>
    #include <iomanip>
    #include <string>
    #include <fstream>
    #include <assert.h>

    using namespace std;
    using namespace System;
    struct TStudent { char month[10];
                      int numBoys[2];
                      int numGirls[2];
                      int sumStudents[2];
                      int totBoys[3];
                      int totGirls[3];
                      int totStudents[3];
                     };
    const char* AUTHOR  = "Sally George              Assignment #1 nn";
    int i;
    void main() {
        TStudent Student;
        Console::Clear();
        cout << AUTHOR;
    ifstream Infile("P01.DAT");
    assert(Infile);
      for (i=1; i<=12; i++)
      {   Infile.get(Student.month, 4);
          Infile.ignore(1);
          // Infile >> Student.numBoys;
          strupr(Student.month);
          cout << Student.month << endl;
          Infile.ignore(80, 'n');
      }
}

您可能需要单独输入数组元素,例如:

Infile >> Students.numBoys[0];
Infile >> Students.numBoys[1];

std。除char数组外,C 不为数组定义>>操作员。