Last active
December 30, 2015 22:29
-
-
Save theasder/7894534 to your computer and use it in GitHub Desktop.
Побайтовое считывание
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void readbyte(int f, void *p, unsigned int size) { | |
int i, status; | |
unsigned char* ptr = p; | |
for(i = 0; i < size; i++) { | |
status = -1; | |
while(status != 1) // считываем до тех пор, пока рид действительно не считает 1 байт | |
status = read(f, ptr, 1); // записываем результат считывание, -1 если ошибку выдали | |
ptr++; // увечиваем на один байт указатель места считывания | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment