https://github.com/adwaith-rajesh/strfuncs
A custom string library in C
https://github.com/adwaith-rajesh/strfuncs
c library string
Last synced: 12 months ago
JSON representation
A custom string library in C
- Host: GitHub
- URL: https://github.com/adwaith-rajesh/strfuncs
- Owner: Adwaith-Rajesh
- Created: 2022-07-31T15:24:28.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-31T15:25:59.000Z (over 3 years ago)
- Last Synced: 2025-01-13T23:24:49.670Z (about 1 year ago)
- Topics: c, library, string
- Homepage: https://gitlab.com/adwaithrajesh/strfuncs
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# strfuncs
A custom string library in C
Source Code -> [https://gitlab.com/adwaithrajesh/strfuncs](https://gitlab.com/adwaithrajesh/strfuncs)
## Why a custom C lib
why not.
## Usage
- Clone the repo
```bash
git clone https://gitlab.com/adwaithrajesh/strfuncs.git
```
- Compile the library
```bash
make libstrfuncs.so
```
This should make a `libstrfuncs.so` file in the current directory.
Now you can move the `libstrfuncs.so` file and the header file from the src
dir to your preferred dir.
Lets go through a test use case.
After cloning the repo and moving the file, I've the following file structure.
```commandline
.
├── include
│ └── strfuncs.h
├── lib
│ └── libstrfuncs.so
└── main.c
```
- contents of `main.c` (and the list of all the available funcs)
```c
#include
#include "strfuncs.h"
int main(void) {
printf("char count %ld\n", char_count("Hello World", 'l'));
printf("is lower %d\n", is_lower("hello"));
printf("is upper %d\n", is_upper("HELLO"));
printf("is digit %d\n", is_digit("23423"));
printf("is alpha %d\n", is_alpha("hElLO"));
printf("startwith %d\n", startswith("Hello", "He"));
}
```
- compiling `main.c`
```commandline
gcc main.c -I./include -L./lib -lstrfuncs -o main
```
```commandline
LD_LIBRARY_PATH=./lib ./main
char count 3
is lower 1
is upper 1
is digit 1
is alpha 1
startwith 1
```
### using strfuncs without making a shared lib
Copy the two file in the `src` dir to your project folder.
```commandline
.
├── main.c
├── strfuncs.c
└── strfuncs.h
```
the you can compile the files to binary using the following command
```commandline
gcc main.c strfuncs.c -o main
```
```commandline
./main
char count 3
is lower 1
is upper 1
is digit 1
is alpha 1
startwith 1
```
#### Notes 😀
I'm a complete noob when it comes to C. So if you feel that the code is 'dangerous' or can
be made more efficient then please create an issue [here](https://gitlab.com/adwaithrajesh/strfuncs/-/issues) and help me fix my mistake.