Reactos
at master 30 lines 593 B view raw
1// 2// wcsrev.cpp 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// Defines _wcsrev(), which reverses a wide chraacter string in place. The 7// pointer to the string is returned. 8// 9#include <string.h> 10 11 12 13extern "C" wchar_t* __cdecl _wcsrev(wchar_t* const string) 14{ 15 // Find the end of the string: 16 wchar_t* right = string; 17 while (*right++) { } 18 right -= 2; 19 20 // Reverse the strong: 21 wchar_t* left = string; 22 while (left < right) 23 { 24 wchar_t const c = *left; 25 *left++ = *right; 26 *right-- = c; 27 } 28 29 return string; 30}