Warning: array subscript has type char

Simple, change

char j;

to

unsigned char j;

or to just a plain (u)int

unsigned int j;
int j;

From GCC Warnings

-Wchar-subscripts Warn if an array subscript has type char. This is a common cause of error, as programmers often forget that this type is
signed on some machines
. This warning is enabled by -Wall.

The compiler doesn’t want you to inadvertantly specify a negative array index. And hence the warning!

Leave a Comment