There's 2 problem with your code.
1st. Your height and width variables are switched (you assigned "i" to width and "j" to height then used image[i][j]) (this is reason behind the error messages!)
Sol.--> Either change "i" to height and "j" to width in for loops. Or change "image[i][j]" to "image[j][i]" everywhere.
2nd. Your average value of RGB is being calculated as an int. That means all decimal points are being dropped from result. (your code will fail check50)
Sol.--> replace "3" with a "3.0" and use round function to round off the float to an int (round gives rounded values away from zero while calculating directly to int gives value closer to zero there's no visible difference in result images but check50 will find this error)
for (int i = 0; i < height; i++)
for (int j = 0; j < width; j++)
int greysc = round((image[i][j].rgbtRed + image[i][j].rgbtGreen + image[i][j].rgbtBlue) / (3.0));
image[i][j].rgbtRed = greysc;
image[i][j].rgbtGreen = greysc;
image[i][j].rgbtBlue = greysc;