🧵 str
Painfully common string utilities for C
Loading...
Searching...
No Matches
str Struct Reference

A string "slice", which is a pointer & length pair. More...

#include <str.h>

Data Fields

char * data
 Pointer to the start of the string.
size_t len
 The length of the string.

Detailed Description

A string "slice", which is a pointer & length pair.

A str can be printed using the "%.*s" format specifier:

str s = str_from_cstr("World!");
printf("Hello %.*s", (int)(s.len), s.data);
str str_from_cstr(char *sz)
Constructs a non-owning str from a null-terminated C-string.
Definition str.c:23
A string "slice", which is a pointer & length pair.
Definition str.h:30
char * data
Pointer to the start of the string.
Definition str.h:32
size_t len
The length of the string.
Definition str.h:37

Field Documentation

◆ len

size_t str::len

The length of the string.

If the string starting at data is null-terminated, this length includes the null terminator.


The documentation for this struct was generated from the following file: