Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does _stscanf_s do?

Tags:

c++

c

mfc

I saw this function in some code and I can't find documentation on google about it. Can someone explain what it does and are there any alternatives to this ?

Thanks.

like image 648
Adrian Avatar asked Jun 27 '11 07:06

Adrian


People also ask

What does %n do in Sscanf?

When we use the %n specifier in scanf() it will assign the number of characters read by the scanf() function until it occurs.

How do you know if Sscanf fails?

sscanf() Return value If successful, the sscanf() function returns the number of receiving arguments successfully assigned. If a matching failure occurs before the first receiving argument was assigned, returns zero. If input failure occurs before the first receiving argument was assigned, EOF is returned.


2 Answers

See http://msdn.microsoft.com/en-us/library/tsbaswba%28VS.80%29.aspx: it is a generic name for sscanf_s.

EDIT: which is conveniently documented here. _stscanf_s is in TCHAR.H on Windows platforms. You can probably get away with using sscanf_s or swscanf_s.

like image 198
Femi Avatar answered Sep 24 '22 15:09

Femi


This MSDN article shows the _stscanf_s variant of their "secure" sscanf replacements:

http://msdn.microsoft.com/en-us/library/t6z7bya3(v=vs.80).aspx

It is a TCHAR variant, which means that it should be able to support ANSI characters, and Unicode/Multi-byte, depending on how the app is compiled.

You could (somewhat) replace it with sscanf on a more generic C/C++ implementation.

like image 40
Merlyn Morgan-Graham Avatar answered Sep 24 '22 15:09

Merlyn Morgan-Graham