Last active
March 20, 2018 14:53
-
-
Save croepha/6fa3f9b9d9bc9039f5af22220cc82175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "stb/stretchy_buffer.h" | |
struct StringStretchyBuffers { | |
char *string_space; | |
size_t*strings ; | |
}; | |
void push_string(struct StringStretchyBuffers*ssb, char*str) { | |
size_t str_start = sb_count(ssb->string_space); | |
while(*str) { | |
sb_push(ssb->string_space, *str++); | |
} | |
sb_push(ssb->string_space, 0); | |
sb_push(ssb->strings, str_start); | |
} | |
int main () { | |
struct StringStretchyBuffers ssb = {0,0}; | |
push_string(&ssb, "The"); | |
push_string(&ssb, "ultamate"); | |
push_string(&ssb, "answer"); | |
push_string(&ssb, "is"); | |
push_string(&ssb, "fourty-two"); | |
printf("FOOO\n"); | |
for (int i=0;i<sb_count(ssb.strings); i++) { | |
printf("%d: '%s'\n", i, ssb.string_space+ssb.strings[i]); | |
} | |
printf("BAHR\n"); | |
sb_free(ssb.string_space); sb_free(ssb.strings); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment