mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Create safe_gets.c
This commit is contained in:
parent
1448149ea2
commit
ac8d8b1a38
23
strings/safe_gets.c
Normal file
23
strings/safe_gets.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <windows.h>
|
||||
#include <strsafe.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#define BUF_LEN 8191
|
||||
|
||||
int wmain(void) {
|
||||
|
||||
wchar_t buf[BUF_LEN] = {0};
|
||||
HRESULT r = StringCchGetsW(buf, ARRAYSIZE(buf));
|
||||
|
||||
if (SUCCEEDED(r)) {
|
||||
|
||||
wprintf(L"You have entered: %ls\n", buf);
|
||||
|
||||
} else {
|
||||
|
||||
wprintf(L"StringCchGets() failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user