gcc/borland and sscanf format specifiers
I guess it was a mistake to trust cygwin gcc 3.2 alone for the last weeks. I've just compiled my application with the Borland Command Line Tools 5.5.x. But this time the command line interface - provided by http://argtable.sourceforge.net/ - wouldn't work correctly.
I checked the argtable library function for parsing the command line and found this:
This first error (str,"%i %n"...) was obvious. I just wonder why GCC 3.2 didn't warn me? Does GCC ignore such spaces in fomat strings or correct such errors quietly or - to make it even worse - not notice them at all? After removing the space the Borland compiled program would work as expected.
/*-- scan an int value --*/
// eliminated space between %i and %n to make it work with borland
if (sscanf(str,"%i %n",&intval,&length) !=1)
But then I found this some lines below:
I do not have the experience to tell wether this space at the beginning of the format string is a source of problems. Sadly, I can't find a note on spaces in format strings in the ANSI-C standard. What I remember is my Prof. saying that spaces in format string of scanf and related functions are "deadly".
/*-- scan for quoted string fist, if no good then try unquoted --*/
if (sscanf(str," '%[^']'%n",strval,&length) != 1)
// is the space after str," a problem?
Any help is really appreciated.