[Bug 13091] Input error compiling c++ sources with mingw

wine-bugs at winehq.org wine-bugs at winehq.org
Thu Nov 13 05:26:05 CST 2008


http://bugs.winehq.org/show_bug.cgi?id=13091





--- Comment #13 from Jeff Zaroyko <jeffz at jeffz.name>  2008-11-13 05:26:05 ---
Created an attachment (id=17257)
 --> (http://bugs.winehq.org/attachment.cgi?id=17257)
related problem

ok -- ignoring the silly practice of mixing scanf and gets in the original
report, at a glance there does appear to be a related issue with the %d format
specifier

It consumes a trailing whitespace character incorrectly, so given the following
related testcase[1], input the number 1 followed by enter, on windows it
converts the 1 and stores it at &i then converts the newline and stores it at
&c.

Under Wine, %d eats both a 1 and the newline and continues reading input
attempting the %c conversion.  Attached is my suggested fix.

[1]:
#include <stdio.h>
int main(void)
{
  int i,ret;
  char c;
  printf("press the number 1 then hit enter\n");
  ret = scanf("%d%c",&i,&c);
  if(ret == 2)
  {
    printf("expecting 1 10: got :%d %d\n");
  }
  return 0;
}


-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list