mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Create safe_concat.c
This commit is contained in:
parent
f0d35c6d50
commit
e931200175
30
strings/safe_concat.c
Normal file
30
strings/safe_concat.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <windows.h>
|
||||
#include <strsafe.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#define BUF_LEN 256
|
||||
|
||||
int wmain(void) {
|
||||
|
||||
wchar_t buf[BUF_LEN] = {0};
|
||||
|
||||
HRESULT r = StringCchCatW(buf, BUF_LEN, L"Hello ");
|
||||
|
||||
if (FAILED(r)) {
|
||||
|
||||
wprintf(L"StringCchCatW() failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
r = StringCchCatW(buf, BUF_LEN, L"there");
|
||||
|
||||
if (FAILED(r)) {
|
||||
|
||||
wprintf(L"StringCchCatW() failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
wprintf(L"%ls\n", buf);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user