From c9ec089ade3a47db1184e12a7dbfdded1abb2768 Mon Sep 17 00:00:00 2001 From: vxunderground <57078196+vxunderground@users.noreply.github.com> Date: Thu, 14 Jul 2022 22:15:08 -0500 Subject: [PATCH] Create WCharStringToCharString.cpp --- String Manipulation/WCharStringToCharString.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 String Manipulation/WCharStringToCharString.cpp diff --git a/String Manipulation/WCharStringToCharString.cpp b/String Manipulation/WCharStringToCharString.cpp new file mode 100644 index 0000000..f51a90f --- /dev/null +++ b/String Manipulation/WCharStringToCharString.cpp @@ -0,0 +1,15 @@ +SIZE_T WCharStringToCharString(PCHAR Destination, PWCHAR Source, SIZE_T MaximumAllowed) +{ + INT Length = (INT)MaximumAllowed; + + while (--Length >= 0) + { +#pragma warning( push ) +#pragma warning( disable : 4244) + if (!(*Destination++ = *Source++)) + return MaximumAllowed - Length - 1; +#pragma warning( pop ) + } + + return MaximumAllowed - Length; +}