vector's operator [] access existing elements; it doesn't create new elements. You start with an empty vector so
v[i] = randomIDChar();
access beyond the vector's end. You could change this to
v.push_back(randomIDChar());
Note that there is also a problem with randomIDChar
. You should only seed the random number generator once, probably before calling either of the functions posted. Any given seed will generate a predictable stream of 'random' numbers; time(0)
returns a number of seconds so every call you make within 1 second will have the same seed and so will generate the same number when you later call rand