_stscanf_s

标准c语言里有scanf和sscanf,它们只是输入源不同而已,前者是标准输入源stdin,后者是字符串作为输入源;
_stscanf_s与其类似,后缀【_s】表示它更安全(security);其中【t】(type)表示它同时兼容宽字符;

PTSTR deviceId = "PCI\VEN_8086&DEV_3B3C&SUBSYS_04401028&REV_06\3&11583659&0&D0";
ULONG ven = 0, dev = 0, sub = 0, rev = 0;

if (_stscanf_s(deviceId,
   _T("PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x"),
   &ven, &dev, &sub, &rev) != 4)
   {...}

执行上述代码后  
ven: 0x00008086  
dev: 0x00003b3c  
sub: 0x04401028  
rev: 0x00000006 


关于sscanf,可参见:
sscanf,sscanf_s及其相关用法
http://www.cnblogs.com/kex1n/archive/2011/06/09/2076501.html

 

你可能感兴趣的:(_stscanf_s)