Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 204207 Details for
Bug 285098
scanf() and strtoul() disagreeing on hex parsing
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Test program from the URL referenced.
test.c (text/plain), 1018 bytes, created by
Martin Baute
on 2009-09-15 15:24:15 UTC
(
hide
)
Description:
Test program from the URL referenced.
Filename:
MIME Type:
Creator:
Martin Baute
Created:
2009-09-15 15:24:15 UTC
Size:
1018 bytes
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> > >int main() >{ > char * string = "0xz"; // valid hex prefix, followed by invalid digit > int i = -1; // result value, initialized to impossible value > int count = -1; // count of scanf()-parsed characters, likewise initialized > char c; // holds first scanf()-unparsed character > char * endptr = NULL; // points to first strtoul()-unparsed character > > // scan string with scanf(), putting result in i, characters parsed in 'count', > // and the next character to be parsed in 'c'. > sscanf( string, "%x%n%c", &i, &count, &c ); > // print results > printf( "sscanf(): Value %d - Consumed %d - Next char %c\n", i, count, c ); > > // scan string with strtoul(), putting result in i, and pointer to next > // character to be parsed in 'c'. > i = strtoul( string, &endptr, 16 ); > // print results > printf( "strtoul(): Value %d - Consumed %d - Next char %c\n", i, ( endptr - string ), *endptr ); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 285098
: 204207