Skip to content

IncludeOnly/string.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

string.h

Get started

wget https://raw.githubusercontent.com/IncludeOnly/string.h/refs/heads/main/string.h

Example

#include <stdio.h>
#define STRING_IMPLEMENTATION
#include "string.h"

int main()
{
    ArenaInit(1024);

    string_t str = String("Hello ");
    string_t str1 = String("World");
    string_t hello = Concat(str, str1);
    hello = Append(hello, String(" and something else   "));
    hello = Trim(hello);

    printf("'%s'\n", hello.chars);
    printf("%d\n", Compare(str, str1));
    printf("%s\n", Substring(hello, 5, 11).chars);
    printf("'%c'\n", CharAt(hello, 6));

    string_array_t words = Split(hello, ' ');
    for(size_t i = 0; i < words.count; i++){
        printf("%s\n", words.strings[i].chars);
    }

    ArenaFree();

    return 0;
}

If you really need to link

mv string.h string.c
cc -o libstring.so string.c -fPIC -DSTRING_IMPLEMENTATION -shared
mv string.c string.h

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages