while( rd = read(fd1, buf, 512) != 0)
{
len += rd;
if(readed < 0)
perror("read: ");
}
MAN pages says, that read() returns number of read bytes, but in my case this code returns number of blocks(depends of 3rd argument) or number of iterations. for example, I have file with 36 symbols and this code returns 1, when all symbols normally read, if I change 512 to 4, it will return 9, and so on. Please correct me and this code to return number of bytes which read with 512 size blocks
rd = read(fd1, buf, 512) != 0
means
rd = (read(fd1, buf, 512) != 0)
The result of != is always either 0 or 1.
You probably meant
while ((rd = read(fd1, buf, 512)) != 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With