fread(ptr,sizeof(*ptr),nitems,stream); if you want 7 bytes and there are only 4 left, do: n = fread(buf,1,7,stdin); /* n will be 4 */ however if you switch the 1 & 7, n will be zero, but 4 bytes will actually be read. to read integers one might do: n = fread(intbuf,2,k,stdin); however, if the byte count is odd, the last integer will be ignored. */