/zString

Simple and beginner-friendly header-only string library useful for the ones who have just started learning C language or for those that want to use an essential string library for their projects

Primary LanguageCMIT LicenseMIT

zString

License: MIT GitHub last commit (branch) GitHub top language

Simple and beginner-friendly header-only string library useful for the ones who have just started learning C language or for those that want to use an essential string library for their projects.

How-To

Just add the zstring.h file to your project's headers and the include and define its IMPLEMENTATION

#define ZSTRING_IMPLEMENTATION
#include "zstring.h"

Test and functionalities

How to setup the test file

For Windows:

$ ./run.bat 

Output > String: 'Hello World' of length 12

For Linux:

$ ./run.sh

Output > String: 'Hello World' of length 12

Functionalities

  • Trim a string
$ ./zstring <string> -tr 
  • Convert all characters to all lowercases
$ ./zstring <string> -tl 
  • Convert all characters to all uppercases
$ ./zstring <string> -tu 
  • Reverse a string
$ ./zstring <string> -re 
  • Remove a word from another string
$ ./zstring <string> -rw -s <wordToRemove> // Case-Sensitive

$ ./zstring <string> -rw -i <wordToRemove> // Case-Insensitive
  • Remove every occurences of a character inside of a string
$ ./zstring <string> -rc -s <charToRemove> // Case-Sensitive

$ ./zstring <string> -rc -i <charToRemove> // Case-Insensitive
  • Compare two strings (Case-Sensitive and Case-Insensitive)
$ ./zstring <string1> -cm -s <string2> // Case-Sensitive

$ ./zstring <string1> -cm -i <string2> // Case-Insensitive
  • Concatenate two strings
$ ./zstring <string1> -cc <string2> 
  • Find the number of words in a string
$ ./zstring <string> -n
  • Find the number of occurances of a characted in a string (Case-Sensitive and Case-Insensitive)
$ ./zstring <string> -o -s <charToFind> // Case-Sensitive

$ ./zstring <string> -o -i <charToFind> // Case-Insensitive
  • Chop a string from left or right by a specific size
$ ./zstring <string> -cp -l -s <sizeToChop> // the flag -l indicates from left and the flag -s indicates by size
$ ./zstring <string> -cp -r -s <sizeToChop> // the flag -l indicates from right and the flag -s indicates by size
  • Chop a string from left or right by a specific number of words
$ ./zstring <string> -cp -l -w <numOfWordsToChop> // the flag -l indicates from left and the flag -w by number of words
$ ./zstring <string> -cp -r -w <numOfWordsToChop> // the flag -l indicates from right and the flag -w by number of words
  • Chop a string from left or right by a delimiter
$ ./zstring <string> -cp -l -d <delimiter> // the flag -l indicated from left and the flag -d by the delimiter 
$ ./zstring <string> -cp -r -d <delimiter> // the flag -r indicated from right and the flag -d by the delimiter 
  • Convert a float to a rationalized String
$ ./zstring <float> -ra

Note: It only works with ASCII characters right now.