0

I wanted every variable in the array to have .x, .y, and .cont, the error occuired on line 11:

#include <iostream>

using namespace std;

struct attrib{
char x;
int y;
char cont;
}

attrib brd[8][8]; //ERROR WAS HERE

int main()
{
    for ( x=-1; X<8; x++) //accesses all columns in the array
    {
        for ( y=-1; y<8; y++) //accesses all rows in the array
            {
            brd[x][y].x= char (65 +x); //assigns columns names A-H
            brd[x][y].y= y +1; //assigns rows numbers 1-8
            cout<< "|" << brd[x][y].x brd[x][y].y << "|";
            }
            cout<<"/n";
    }
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Unimportant
1

Edit: You should remember that error message specifically, because it is a misleading one for less experienced programmers.

struct attrib{
char x;
int y;
char cont;
}; // <-- you didn't have a trailing semicolon
 
attrib brd[8][8]; //ERROR WAS HERE <-- no it wasn't

Edited by Unimportant: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.