libgraph --- Implementing Turbo C's graphics on GNU/Linux

<<Previous Next>>
Developer Section COPYING Information


 Bugs & Caveats

  • scanf()


  • scanf()
  • CAVEAT : scanf input buffer is limited to 256 characters. This means that it will stop accepting input after you enter 256 characters. This behaviour is unlike the normal scanf function that allows you to enter arbitrarily long strings and scans only the required amount of characters. You can increase the buffer size by changing the definition SCAN_BUF in grtext.h and recompiling.

    Another thing is that scanf can only perform 10 input conversions in one call i.e. it can process an input string with maximum 10 %. Even this feature is a pure hack since "C does not provide any way of determining the number of arguments recieved" by a variadic function like scanf. Basically we just scan the format string over an arbitrary constant string of 10 integers to determine the number of arguments and scan the users input at every enter keypress to see if we've got all we expected.

    Unfortunately this only fixes the number-of-arguments problem. There is still no way of determining what rubbish the user has entered, which is why the function goes into a loop when characters are entered where numbers are expected. This was overcome by providing a special clause CTRL-C to quit the program altogether. Don't blame us, the info-page itself says that there is no way of recovering from a scanf error.


    <<Previous <Home> Next>>
    Developer Section Top COPYING Information