Created
August 14, 2015 22:43
-
-
Save k-takata/07764e23815a3959d431 to your computer and use it in GitHub Desktop.
VC14's sscanf returns different value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int i, d, n, ret; | |
char *strs[] = {"3", "3x", "3\x80", "3\xf0", "3\xfe", "3\xff"}; | |
for (i = 0; i < sizeof(strs) / sizeof(strs[0]); i++) { | |
ret = sscanf(strs[i], "%d%n", &d, &n); | |
printf("str=%s: d=%d, n=%d, ret=%d\n", strs[i], d, n, ret); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VC7, VC10, Cygwin:
VC14:
When an input string is "3\xff", VC14's sscanf sets 2 to
n
.