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 tobuf
The number of characters at the end of / code> your
// do stuff potential incrementline
buf + BUFSIZE one After the letter <4> >>buf
buf + BUFSIZE - line There is an integral number pointing to / em>line tobuf + BUFSIZE - and therefore the number of characters that you can safelylinecan be typed without any overflowbuf <
Comments
Post a Comment