Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bug when using _Dest _Console
#19
Using "scanf()" could be a pain. However cannot use "gets()" in its place because it doesn't check for the target buffer size, and using string-to-number conversions like "atol()" are clunky. Could use "fgets()" instead for string input from "stdin". Another thing is that "scanf()" or alike function doesn't prevent the user from typing a non-numeral, or a plus or minus sign or multiple decimal points out of place. That's why all the checking in "qbs_input()" within "libqb.cpp" is needed. The CRT, for "scanf()" is hardwired to stop at a certain number of characters depending on the format which is "%ld" or alike. I don't know that much about C/C++ programming but I did enough to tell you that I had to avoid using "scanf()" although I was compelled to use "fscanf()" for input files and "sscanf()" for a few other things.

I looked at the screenshot. "scanf()" only picks up as many characters as it thinks should fit into the type asked for by the "format" first parameter it's given, that's why it displayed strange values in the first and second attempts. If it's going to convert improperly like that, it's not going to matter if it could accept 10 digits or 100 digits.
Reply


Messages In This Thread
bug when using _Dest _Console - by Jack - 09-13-2022, 10:18 PM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-13-2022, 10:51 PM
RE: bug when using _Dest _Console - by bplus - 09-14-2022, 12:31 AM
RE: bug when using _Dest _Console - by Jack - 09-14-2022, 12:34 AM
RE: bug when using _Dest _Console - by bplus - 09-14-2022, 12:43 AM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-14-2022, 03:43 AM
RE: bug when using _Dest _Console - by Jack - 09-14-2022, 04:30 AM
RE: bug when using _Dest _Console - by Pete - 09-14-2022, 05:24 PM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-14-2022, 04:42 AM
RE: bug when using _Dest _Console - by bplus - 09-14-2022, 02:09 PM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-14-2022, 03:27 PM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-14-2022, 04:40 PM
RE: bug when using _Dest _Console - by Pete - 09-14-2022, 04:14 PM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-14-2022, 06:52 PM
RE: bug when using _Dest _Console - by bplus - 09-14-2022, 07:07 PM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-14-2022, 07:38 PM
RE: bug when using _Dest _Console - by Pete - 09-14-2022, 07:53 PM
RE: bug when using _Dest _Console - by mnrvovrfc - 09-16-2022, 08:45 PM
RE: bug when using _Dest _Console - by Pete - 09-16-2022, 09:11 PM
RE: bug when using _Dest _Console - by Pete - 09-20-2022, 08:12 PM



Users browsing this thread: 12 Guest(s)