[Solved] What does the following bit of code mean/do?


The semicolon at the end of that statement makes the if statement completely useless.

After removing the semicolon, that if statement is extremely bad form, and should be either rewritten as

if ( (ret_val = fgets(st, n, stdin)) != NULL )
{
}

or

ret_val = fgets(st, n, stdin);
if ( ret_val )
{
}

The reason it’s bad form is that it’s a common error to mistakenly use an assignment operator = where the equality operator == was intended. The two forms shown above make it clear that the assignment was intentional, and not just a typo.

0

solved What does the following bit of code mean/do?