Files
Digital-Research-Source-Code/CPM OPERATING SYSTEMS/CPM 86/CONCURRENT/CCPM-86 3.1 SOURCE/D6/REVERSE.C
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

28 lines
896 B
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*----------------------------------------------------------------------*\
| NAME : reverse |
| CREATED : 16-August-83 LAST MODIFIED: 16-August-83 |
| FUNCTION: Reverse reverses a string in place. |
| INPUT : str -- ptr to string that will be reversed.|
| OUTPUT : Reverses string pointed to by str in place. |
| No return value. |
\*----------------------------------------------------------------------*/
#include <portab.h>
#include "utildef.h"
VOID reverse( str )
BYTE str[]; /* string to reverse */
{
WORD head; /* head of string index */
WORD tail; /* tail of string index */
WORD cbuff; /* current char. buffer */
for( head=0,tail=strlen( str )-1; head < tail; head++,tail-- )
{
cbuff = str[head];
str[head] = str[tail];
str[tail] = cbuff;
}
}