mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 17:45:06 +00:00

Imported from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource/10.0.22621.3 License: MIT
30 lines
593 B
C++
30 lines
593 B
C++
//
|
|
// wcsrev.cpp
|
|
//
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//
|
|
// Defines _wcsrev(), which reverses a wide chraacter string in place. The
|
|
// pointer to the string is returned.
|
|
//
|
|
#include <string.h>
|
|
|
|
|
|
|
|
extern "C" wchar_t* __cdecl _wcsrev(wchar_t* const string)
|
|
{
|
|
// Find the end of the string:
|
|
wchar_t* right = string;
|
|
while (*right++) { }
|
|
right -= 2;
|
|
|
|
// Reverse the strong:
|
|
wchar_t* left = string;
|
|
while (left < right)
|
|
{
|
|
wchar_t const c = *left;
|
|
*left++ = *right;
|
|
*right-- = c;
|
|
}
|
|
|
|
return string;
|
|
}
|