strinit(3pub)

strinit3pub

Initialize a string with a given character to a given length

Usage

#include <publib.h>
char *strinit(char *s, int c, size_t len) {

Overview

strinit initializes the string pointed to by s to be of length len, all characters being c, where the terminating '\0' is not included in the length, i.e., the string will use len+1 characters.

Return value

strinit will return s.

Examples

To initialize a string to consist of twenty underscores, one would do the following.

#include <publib.h>
char string[21];     /* note 21 to make room for '\0' */
strinit(string, '_', 20);

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.