C function like stdlib's fgets but reads until null instead of newline.