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

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -