I'm trying to read a png file with read() and open() in C, but all I'm getting is corrupted data. Here is my code :
int r;
int fd;
char buff[4097];
fd = open("image.png", O_RDONLY);
while ((r = read(fd, buff, 4096)) > 0)
{
buff[r] = '\0';
printf("%s", buff);
}
close(fd);
The 8-10 first bytes are the same and then the data is corrupted and doesn't match at all the original image. Thanks for your help