From: Michael D. Lowis Date: Tue, 12 Aug 2014 19:32:48 +0000 (-0400) Subject: Implemented str_set X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=e273d279e4fb59de7eafa7ab265224b2b3667084;p=projs%2Flibcds.git Implemented str_set --- diff --git a/source/string/str.c b/source/string/str.c index eeed415..5d58ac3 100644 --- a/source/string/str.c +++ b/source/string/str.c @@ -55,10 +55,14 @@ char str_at(str_t* p_str, size_t index) str_t* str_set(str_t* p_str, size_t index, char val) { - (void)p_str; - (void)index; - (void)val; - return NULL; + str_t* p_newstr = NULL; + assert(NULL != p_str); + if (index < p_str->size) + { + p_newstr = str_copy(p_str); + p_newstr->data[index] = val; + } + return p_newstr; } str_t* str_concat(str_t* p_str1, str_t* p_str2)