简体   繁体   English

在哪个头文件中声明了函数“ _tcscpy_s”?

[英]In what header file the function `_tcscpy_s` is declared?

Visual Studio 2015. I am reading the " Windows via C\\C++ " book and try to use its code samples. Visual Studio2015。我正在阅读《 通过C \\ C ++的Windows 》一书,并尝试使用其代码示例。 Author writes that the "safe" functions of string have the _s suffix and are declared in the StrSafe.h header. 作者写道,字符串的“安全”功能具有_s后缀,并在StrSafe.h标头中声明。 This header are to be the last in the list of includes. 此标头将是包含列表中的最后一个。 In my code I included such headers: 在我的代码中,我包含了以下标头:

#include <iostream>
#include <exception>
#include <string>
#include <Windows.h>
#include <strsafe.h>

But I have a problem: 但是我有一个问题:

// IDE doesn't see the _tcscpy_s function
errno_t result = _tcscpy_s(szBuffer, _countof(szBuffer), TEXT("0123456789"));

I looked for info about the _tcscpy_s function, but I didn't see info about its header file (I expected that it is strsafe.h ). 看了有关信息_tcscpy_s功能,但我没有看到它的头文件信息(我所料,这是strsafe.h )。

How can I fix it? 我该如何解决?

Just like any other "Generic Text" string function version, the _tcscpy_s() function is declared in TCHAR.H (as mentioned in the documentation ). 就像任何其他“通用文本”字符串函数版本一样, _tcscpy_s()函数在TCHAR.H声明(如文档中所述)。

Add #include <tchar.h> to your code. #include <tchar.h>添加到您的代码中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM