Added strrev function to getch.c

This commit is contained in:
R. Eric Wheeler 2021-01-25 06:58:35 -08:00
parent 382ca844d5
commit 95c5b66fdc
1 changed files with 16 additions and 0 deletions

View File

@ -4,6 +4,22 @@
#include <stdlib.h>
static struct termios oldattr;
static char *strrev(char *str)
{
char *p1, *p2;
if (! str || ! *str)
return str;
for (p1 = str, p2 = str + wcslen(str) - 1; p2 > p1; ++p1, --p2)
{
*p1 ^= *p2;
*p2 ^= *p1;
*p1 ^= *p2;
}
return str;
}
static void setRawMode(void)
{
struct termios newattr;