Skip to content

Instantly share code, notes, and snippets.

@theasder
Last active December 30, 2015 22:29
Show Gist options
  • Save theasder/7894534 to your computer and use it in GitHub Desktop.
Save theasder/7894534 to your computer and use it in GitHub Desktop.
Побайтовое считывание
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