strange C program fgets -
I was going through an open source codebase and I see the following: -
Code> char * buf; Four * line; #define BUFSIZE 5000 buf = malloc (BUFSIZE) line = buff; While (in fgets (line, (unsigned) (buf + BUFSIZE -line))! = NULL) {// do stuff // ....}Why is another < Code> buf + BUFSIZE - line ? The argument given as
line to
buf
The number of characters at the end of / code> your
// do stuff potential increment
line
buf + BUFSIZE one After the letter <4> >>
buf
buf + BUFSIZE - line There is an integral number pointing to / em>
line to
buf + BUFSIZE - and therefore the number of characters that you can safely
line
can be typed without any overflow
buf <
Comments
Post a Comment