c - scanf ("% [^\n]s",a) vs gets (a) - Stack Overflow
This means that scanf("%[^\n]",a) is not capable of reading empty input lines, i.e. lines that contain \n character immediately. If you feed such a line into the above scanf, it will return 0 to indicate failure …