How to properly error trap read in c to get byte number from a file descriptor
问题 I am currently writing a small dummy program to try and get the hang of properly using the read in c. I made a small function called readdata to read from the file descriptor and store in a buffer then return the number of bytes read. My problem is I am trying to correctly error handle and trap things so that there is no buffer overflow but I keep doing something from. Here is the tester: #include <stdio.h> #include <string.h> #include <unistd.h> #define BUFSIZE 10 int readdata(int fd, char