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

And*_*man 0 c++ string winapi visual-studio

Visual Studio2015。我正在阅读《通过C \ C ++的Windows》一书,并尝试使用其代码示例。作者写道,字符串的“安全”功能具有_s后缀,并在StrSafe.h标头中声明。此标头将是包含列表中的最后一个。在我的代码中,我包含了以下标头:

#include <iostream>
#include <exception>
#include <string>
#include <Windows.h>
#include <strsafe.h>
Run Code Online (Sandbox Code Playgroud)

但是我有一个问题:

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

看了有关的信息_tcscpy_s的功能,但我没有看到它的头文件(我希望它是信息strsafe.h)。

我该如何解决?

Ami*_*mit 5

就像任何其他“通用文本”字符串函数版本一样,该_tcscpy_s()函数在中声明TCHAR.H(如文档中所述)。

添加#include <tchar.h>到您的代码。