# LightweightCString **Repository Path**: zlm678/LightweightCString ## Basic Information - **Project Name**: LightweightCString - **Description**: 一个使用C语言编写的轻量化的String库 - **Primary Language**: C - **License**: GPL-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-02-09 - **Last Updated**: 2022-02-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LightweighCString ### Introduction:
A String library implemented in C
It allows you to easily manipulate strings
(I really don't like the string Library of C language. Is there anyone like me?)

### Explain:
This is a library I wrote when developing Tranquility programming language. The reason is that it's too troublesome to use C string when developing programming language
I think the operation is very simple. A few sentences of code can solve the problem of operating strings. Personally, it is very convenient :)

#### Main functions of the Library:
- Initialize String
- Add new string to string
- Add new char to string
- Replace the specified content in the original string with another string
- Used to locate a string in the original data to determine its location
- Clear the contents of the String class
- Get string data
- Get string length


### Some Example:
1. Realize a simple storage and reading
```C #include "LCString.h" int main(){ string a = initStr(); a = addStr(a, "hello, world"); // Add a string // Stdio has been introduced into the String library, // so you don't need to reference it anymore // Get the string in a, Print the contents of a printf("%s\n", getData(a)); } ```

2. Replace the contents of the string
```C #include "LCString.h" int main(){ string a = initStr(); a = addStr(a, "aaabbbccc"); // Add a string // Replace the contents of the string // Reassign the return value to a a = replace(a, "a", ""); // Get the string in a, Print the contents of a printf("%s\n", getData(a)); } ```

3. Find string position
```C #include "LCString.h" int main(){ string a = initStr(); a = addStr(a, "abcd1edguowgue"); // Add a string // Find string position // Note: the index of the first letter in the string is 0 int pos = find(a, "1"); // Print location printf("%d\n", pos); } ```

4. Get string length ```C #include "LCString.h" int main(){ string a = initStr(); a = addStr(a, "abcd1edguowgue"); // Add a string // Get the string length int length = len(a); // Print the length printf("%d\n", length); } ```

### Feedback:
If you have any questions, you can send an email to robotsteve@163.com