Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct s_split_word
- {
- b8 has_new_line;
- char word[128];
- };
- func s_sarray<s_split_word, 128> split_str(char* text)
- {
- s_sarray<s_split_word, 128> result;
- char* start = text;
- int char_i = 0;
- while(true)
- {
- char c = text[char_i];
- if(c == ' ' || c == '\n' || c == 0)
- {
- s_split_word split_word = zero;
- if(c == '\n')
- {
- split_word.has_new_line = true;
- }
- char* end = &text[char_i];
- memcpy(split_word.word, start, (u32)(end - start));
- arr_add(&result, split_word);
- start = &text[char_i + 1];
- }
- if(c == 0) { break; }
- char_i += 1;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement