source: buchla-68k/libsm/strrev.c@ 7258c6a

Last change on this file since 7258c6a was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Use standard integer types.

  • Property mode set to 100644
File size: 848 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
16int8_t *strrev(int8_t *s1, int8_t *s2)
17{
18 register int8_t *s3;
19 register int32_t i;
20
21 i = 0L; /* initialize string length */
22 s3 = s1; /* initialize target left end pointer */
23
24 while (*s2) { /* find right end of source string */
25
26 ++s2;
27 ++i;
28 }
29
30 --s2; /* adjust source right end pointer */
31
32 while (i--) /* copy string in reverse */
33 *s3++ = *s2--;
34
35 *s3 = '\0'; /* terminate the string */
36 return(s1); /* return address of reversed string */
37}
Note: See TracBrowser for help on using the repository browser.