In C programming, character buffers are used for string implementation. habitually we are clear the content before we use any character buffer in any scope. I need a clarification on cleaning a char buffer when the char buffer is using several times within the same scope. e.g. within the below function I am using char buffer[BUF_SIZE].
void function foo(char *p_char)
{
char buffer[BUF_SIZE];
memset(buffer, '\0', BUV_SIZE-1);
strcpy(buffer, p_char);
..
..
// after some codes.
strcpy(buffer, "second time use of buffer");
}
in above function, buffer is used twice, at the second place do I need to call memset() to clean the previous content in buffer ? likewise when using a char buffer do I always clean it before assign a value (if values are assigning several times to the buffer within same scope) ?