source: buchla-68k/orig/CLIBRARY/STRREV.C@ 9bf0f86

Last change on this file since 9bf0f86 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 895 bytes
Line 
1/*
2 =============================================================================
3 strrev.c -- reverse a string
4 Version 1 -- 1988-02-03 -- D.N. Lynx Crowe
5
6 char *
7 strrev(s1, s2)
8 char *s1;
9 char *s2;
10
11 Copies string 's2' into 's1'. 's1' must be large enough
12 to hold 's2'. Returns 's1'.
13 =============================================================================
14*/
15
16char *
17strrev(s1, s2)
18char *s1;
19register char *s2;
20{
21 register char *s3;
22 register long i;
23
24 i = 0L; /* initialize string length */
25 s3 = s1; /* initialize target left end pointer */
26
27 while (*s2) { /* find right end of source string */
28
29 ++s2;
30 ++i;
31 }
32
33 --s2; /* adjust source right end pointer */
34
35 while (i--) /* copy string in reverse */
36 *s3++ = *s2--;
37
38 *s3 = '\0'; /* terminate the string */
39 return(s1); /* return address of reversed string */
40}
Note: See TracBrowser for help on using the repository browser.