Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jstringtypes

a tiny string library written in C because apparently managing memory manually sounded like a good idea and that C didn't give me enough suffering already (turns out to be FALSE MID-WAY... i'm DYING)

About

basically, this is my first C library, and i am making it to learn how C actually handles strings and memory instead of hiding everything behind some nice convenient code like other languages do (abstraction)

the library currently has an owned string (mutable) type and a non-owning string_view type (immutable; read-only), with some basic operations for both

Features

  • string -- a mutable, owned, dynamically allocated string type
  • string_view -- an immutable, non-owning view into existing string data

Requirements

  • GCC - as this C compiler is used for the project

Installation

git clone <insert-repository-url-here>
cd jstringtypes

Usage

#include "include/string.h"
#include "include/string_view.h"

int main(void)
{
    string str = string_from("Hello");
    string_push_char(&str, '!');

    string_print(str);
    putchar('\n');

    string_view view = string_view_from(str.data);
    string_view sub = string_view_substr(view, 0, 5);

    string_view_print(sub);
    putchar('\n');

    string_free(str);

    return 0;
}

License

See LICENSE.

About

a tiny C string library because apparently managing memory manually sounded like a good idea!

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages