[Solved] C read file in byte chunks [closed]


Well if you can’t use man, why not just search for it?

Anyway you are using it wrong. If you want to read it by chunks you should do it like this

// consider that we allocated enough memory for buffer
// and buffer is byte array
ssize_t r = 0, i = 0;
do {
  r = read( fd, buffer + i, 1024 ); // try to read 1024 bytes
  i += r; 
} while( r > 0 ); 

solved C read file in byte chunks [closed]