Giter Site home page Giter Site logo

cn_string's Introduction

CN_String

A C library that makes Null-Terminated strings less of a pain in the arse.

CN_String is a library which helps users handle strings in a more "object-oriented" way in C. Chances are that you have been spoiled by std::string in C++. Getting string length in C is NOT constant time, meanwhile it is in C++. Also concatenation isn't as trivial in C as opposed to C++. This library supplies functions for enhanced string handling. You can concatenate and insert into CN_Strings, and it supports C-Strings as well. This library is similar to CN_Vec as in it handles dynamic memory management on its own, but it guarantees that its data will contain an empty string at least as opposed to a NULL pointer when empty with no text.

Example:

#include <stdio.h>
#include <stdlib.h>

#include "cn_string.h"

main() {
	//Starting with a blank string
	CN_STRING str = cn_string_init();
	cn_string_set_from_cstr(str, "This is a test.");
	printf("%s\n", cn_string_str(str));
	cn_string_free(str);
	
	//Starting with initial string
	CN_STRING str_i = cn_string_from_cstr("This is also a test.");
	printf("%s\n", cn_string_str(str_i));
	cn_string_free(str_i);
}

Output:

This is a test.
This is also a test.

Full documentation at: http://web.eecs.utk.edu/~ssmit285/lib/cn_string/index.html
The documentation has details and examples of every single function in the library, as well as a guide.

cn_string's People

Contributors

idestykk avatar

Watchers

James Cloos avatar  avatar

Forkers

moneytech

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.