본문으로 바로가기

Simple Dynamic Strings

category Devlogs 2024. 3. 15. 11:00

홈페이지: https://github.com/antirez/sds

C용 스트링 처리 라이브러리로.. 아래를 지원

Concatenating, Formatting, Trimming strings and getting ranges, Fast number to string operations, String copying, Quoting strings, Tokenization, String joining

아래는 concat의 예제로 메모리를 자동으로 동적 할당.

#include <sds.h>
 
void test(char **s)
{
    *s = sdscat(*s, "foo");
    *s = sdscat(*s, "bar");
    *s = sdscat(*s, "123");
}
 
void main(void)
{
    sds s;
    s = sdsempty();
    s = sdscat(s, "foo");
    s = sdscat(s, "bar");
    s = sdscat(s, "123");
    printf("%s\n", s);
    sdsfree(s);
 
    s = sdsempty();
    test(&s);
    printf("%s\n", s);
    sdsfree(s);
}




Korea Tcl/Tk Community
블로그 이미지 ihmin 님의 블로그
VISITOR 오늘 / 전체