Following up on ouah's answer. If you have
char buffer[5] = { 0 } ;
int main(int argc, char **argv)
{
memset ( buffer, 0, sizeof buffer);
...
There might be one exception: If you really do low level C programming (without an operating system) and your C program is called directly without a fully working environment, then the buffer
array might not be initialized correctly in this case, because the necessary initialization code (the code running before main
) is missing.
In this case it's the other way round: The initialization is useless (because it does not work in this particular environment) and the memset
is necessary.
But as I said: This really only happens with extreme low level C programming and is actually a bug in the environment, which gives you a non-C conforming environment.