I was writing a simple program to read a 24-bit RGB image, convert it into an 8-bit grayscale image and write it back into a file. What's wrong with my code?

#include<stdio.h>
#include<conio.h>...