mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Create security_enhanced.c
This commit is contained in:
parent
fe6be83b1d
commit
0625b84cd5
34
strings/security_enhanced.c
Normal file
34
strings/security_enhanced.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#define BUF_LEN 25
|
||||
|
||||
int wmain(void) {
|
||||
|
||||
wchar_t str1[] = L"There are 15 pines";
|
||||
|
||||
const int MAX_CHARS = 50;
|
||||
size_t count = wcsnlen_s(str1, MAX_CHARS);
|
||||
|
||||
wprintf(L"The length of the string is %ld characters\n", count);
|
||||
|
||||
wchar_t buf[BUF_LEN] = {0};
|
||||
|
||||
int r = wcscpy_s(buf, BUF_LEN, L"Wuthering");
|
||||
|
||||
if (r != 0) {
|
||||
|
||||
wprintf(L"wcscpy_s() failed %ld", r);
|
||||
}
|
||||
|
||||
r = wcscat_s(buf, BUF_LEN, L" heights\n");
|
||||
|
||||
if (r != 0) {
|
||||
|
||||
wcscat_s(L"wcscat_s() failed %ld", r);
|
||||
}
|
||||
|
||||
wprintf_s(buf);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user