strtrim(3pub)

strtrim3pub

Remove leading and trailing whitespace

Usage

#include <publib.h>
char *strtrim(char *s);

Overview

strtrim removes all whitespace characters from the beginning and the end of a string. As whitespace is counted everything for which isspace(3) returns true.

Return value

strtrim returns its argument.

Examples

To remove whitespace from the beginning and end of all lines, you might do the following:

#include <publib.h>
int main(void) {
	char line[512];
	while (fgets(line, sizeof(line), stdio) != NULL) {
		strtrim(line);
		printf("%s", line);
	}
	return 0;
}

Releases

16 releases since Debian 1.2 (Rex); the text changed 4 times.

  1. 1.2–1.3
  2. 2.0–2.2
  3. 3.0
  4. 3.1–6.0
  5. 7–13

Author

Lars Wirzenius ([email protected])

From publib-dev 0.40-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.