A string library for c.
To install stronk on your system. Pull the repository and run the install.sh bash file.
To include it in your c file, write:
#include <stronk.h>To compile it, add -L. -lstronk to your compile command.
Initiates a string.
Include: <stronk.h>
The initialized string.
stronk* stronk_init();Deinitializes a string by freeing up memory allocated by stronk_init().
Include: <stronk.h>
Nothing
void stronk_deinit(stronk* s);Adds a char buffer b with the lenght l to the string s.
Include: <stronk.h>
Nothing
void stronk_add(stronk* s, char* b, int l);Adds a null terminated char buffer b to the string s.
Include: <stronk.h
Nothing
void stronk_add_cstr(stronk* s, char* b);Returns the string s as a null terminated char buffer.
Include: <stronk.h>
The char buffer.
The returned char* is not a copy which means it will be changed under runtime.
char* stronk_get_temp_cstr(stronk* s);Returns the string s as a null terminated char buffer copy.
Include: <stonk.h>
The allocated char buffer.
The returned char buffer needs to be freed after use.
char* stronk_alloc_cstr(stronk* s);Returns the length of the string s.
Include: <stronk.h>
The length.
size_t stronk_len(stronk* s);Clears a string s of its contents so that it can be reused. This can be much more performant than creating a new string because new memory does not have to be allocated.
Include: <stronk.h>
Nothing
void stronk_reset(stronk* s);#include <stdio.h>
#include <stronk.h>
int main() {
// Initialize a string
stronk* s = stronk_init();
// Add a char buffer to the string
stronk_add_cstr(s, "Example string");
// Print string and length
printf("%s\n", stronk_get_temp_cstr(s));
printf("%ld\n", stronk_len(s));
// Deinitialize the string
stronk_deinit(s);
}To contribute to strong, fork the repository and create a new branch with a fitting name. Thereafter create a pull request with your changes.
Stronk was developed in Ubuntu 22.04 LTS and compiled with GCC (GNU compiler collection).