Mashmagar
Mashmagar

Reputation: 2664

What's the difference between _tcsnicmp and _tcsncicmp?

Microsoft documentation shows both _tcsnicmp and _tcsncicmp (note the extra c) as TCHAR.H equivalents of _strnicmp for doing string comparisions. I'm not sure which one I should be using.

What is the difference between the two methods?

My best guess is that the nc version takes a count in number of characters and the n version takes a count in number of bytes.

Upvotes: 3

Views: 3980

Answers (2)

Mark Ransom
Mark Ransom

Reputation: 308392

All of the _tcs functions are actually macros, and will resolve down to an equivalent function depending on which of _UNICODE or _MBCS macros are defined for the build.

Looking at the documentation, the two functions are identical except for the case when _MBCS is defined, in which case they resolve to _mcsnicmp or _mbsnbicmp. The difference between those, as you stated, is whether the count is in characters or bytes.

Upvotes: 5

orlp
orlp

Reputation: 117771

To me it seems you should be using neither.

Identifiers starting with a underscore should only be used by compilers/implementations and not in normal code.

Perhaps you could elaborate more about what you are trying to do?

Upvotes: -1

Related Questions