Convert string to GUID with sscanf

Posted by Andy Li on Stack Overflow See other posts from Stack Overflow or by Andy Li
Published on 2010-05-13T04:43:15Z Indexed on 2010/05/13 4:54 UTC
Read the original article Hit count: 627

Filed under:
|
|

I'm trying to convert a string to GUID with sscanf:

GUID guid;
sscanf( "11111111-2222-3333-4455-667788995511", "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        &guid.Data1, &guid.Data2, &guid.Data3,
        &guid.Data4[0], &guid.Data4[1], &guid.Data4[2],
        &guid.Data4[3], &guid.Data4[4], &guid.Data4[5],
        &guid.Data4[6], &guid.Data4[7]);

However, in runtime, it fails and exits with "Error: Command failed". Why? How to fix it?

I do not want to compile with /clr so cannot use System.

© Stack Overflow or respective owner

Related posts about sscanf

Related posts about c