Implementation of trim_spaces function..
More...
#include "mdb.h"
Go to the source code of this file.
|
char * | trim_spaces (char *s) |
| Trims leading and trailing spaces from a string.
|
|
Implementation of trim_spaces function..
- Copyright
- (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
- (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
- License
- This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
- Author
- M. Borland, C Saunders, R. Soliday
Definition in file trim_spaces.c.
◆ trim_spaces()
char * trim_spaces |
( |
char * | s | ) |
|
Trims leading and trailing spaces from a string.
This function removes all leading and trailing space characters from the input string s
by modifying it in place. It returns a pointer to the trimmed string.
- Parameters
-
s | The string to be trimmed. |
- Returns
- A pointer to the trimmed string.
Definition at line 28 of file trim_spaces.c.
28 {
29 char *ptr;
30 if (strlen(s) == 0)
31 return (s);
32 ptr = s;
33 while (*ptr == ' ')
34 ptr++;
35 if (ptr != s)
37 ptr = s + strlen(s) - 1;
38 while (*ptr == ' ' && ptr != s)
39 ptr--;
40 *++ptr = 0;
41 return (s);
42}
char * strcpy_ss(char *dest, const char *src)
Safely copies a string, handling memory overlap.