STRINIT(3pub)
π STRINIT(3pub) π
okay bestie, welcome to the C Programmer's Manual β this one's a lil baby function from publib and it's literally so simple it's giving main character energy for no reason. let's get into it β¨
πΈ NAME πΈ
strinit β initialize a string with a given character to a given length π
β¨ SYNOPSIS β¨
#include <publib.h>
char *strinit(char *s, int c, size_t len) {
yes the synopsis has a lil stray { on the end, and no we are not gonna touch it, she's iconic like that π
π¦ DESCRIPTION π¦
okay so strinit takes the string that s points to and initializes it to be of length len, with every single character being c.
here's the tea though π« β that terminating '\0' is NOT counted in the length. so the string is actually gonna use len+1 characters. one extra for the null, always, no cap. plan your buffer accordingly bestie, fr fr π
π RETURN VALUE π
strinit will return s. that's it. that's the whole return value. she hands you back the same pointer you gave her. queen behavior π
π EXAMPLE π
say you wanna initialize a string to consist of twenty underscores. here's how you'd do it:
#include <publib.h>
char string[21]; /* note 21 to make room for '\0' */
strinit(string, '_', 20);
see the 21? that's the 20 plus the extra one for '\0'. not me warning you about this twice but likeβ¦ please remember the extra byte π
π SEE ALSO π
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi) β ty for your service king π«Ά
Publib Β· C Programmer's Manual Β· STRINIT(3pub)
and that's the whole page bestie!! π this came to you straight from the Publib corner of the C Programmer's Manual, section 3pub, written by the legend himself Lars Wirzenius (hi lars π
). no version number on the tin, just vibes, just strinit. go forth and fill your buffers with underscores πΈβ¨π¦
π¦ where this page comes from
- debian bookworm: publib-dev 0.40-3+b1 Β· BSD-2-Clause
- debian trixie: publib-dev 0.40-4 Β· BSD-2-Clause
- ubuntu jammy: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu noble: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu questing: publib-dev 0.40-4
- ubuntu resolute: publib-dev 0.40-4build1 Β· BSD-2-Clause
- ubuntu stonking: publib-dev 0.40-4build1 Β· BSD-2-Clause
- Copyright (c) 1994-2006 Lars Wirzenius. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms