I'm trying to finish this assignment, but I got this error.
"subscripted value is neither array nor pointer"

Here are parts of the code.

typedef enum { BOAT = 178, SEA = 250} Appearance;
typedef struct
{
	Appearance appear;
} Square;

typedef struct {
Square ** grid;
int size;
} Board;

The error comes out in here:

for (i = 0; i < size; i++)
    for (j = 0; j < size; j++)
	printf("%c", ((theBoard[j][i]).grid));

Recommended Answers

Show more code.

Jump to Post

All 3 Replies

I'm assuming that theBoard is of type Board.
It gives you this error because you don't have the [ and ] operators defined for the Board type.

Or you could do this(untested):

Instead of this:
printf("%c", ((theBoard[j]).grid));

Use this:
printf("%c", theBoard[j].grid);

Show more code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.