How do I achieve the dynamic equivalent of this static array initialisation:
char c[2] = {}; // Sets all members to \'\\0\';
In other word
Two ways:
char *c = new char[length];
std::fill(c, c + length, INITIAL_VALUE);
// just this once, since it's char, you could use memset
Or:
std::vector c(length, INITIAL_VALUE);
In my second way, the default second parameter is 0 already, so in your case it's unnecessary:
std::vector c(length);
[Edit: go vote for Fred's answer, char* c = new char[length]();]