Skip to content

victorcebarros/str

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

str

A simple library to do string manipulation in C.

str simplifies working with strings in C and targets simplicity as one of its goals.

Example: Checking palindromes

The following program checks whether words passed to it are palindromes or not. It is a rather simple example but it shows some of the library features.

/* ... */
#include "str.h"

void is_palindrome(char const* s) {
    str* word = str_from(s);
    str* reversed = str_clone(word);

    str_reverse(reversed);

    printf("%s is %sa palindrome!\n",
            str_cstr(word),
            str_equal(word, reversed)
                ? ""
                : "not ");

    str_del(reversed);
    str_del(word);
}

int main(int argc, char const** argv) {
    /* ... */

    for (int i = 1; i < argc; ++i) {
        is_palindrome(argv[i]);
    }

    /* ... */
}

You can see the full example under docs/examples. More code snippets will be added in the future.

About

The string manipulation library written in C.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published