I would like to have a dynamic character array who's length equals the loop iteration.
char* output;
for (short i=0; i<2; i++){
output = new char[i+1];
printf("string length: %d\n",strlen(output));
delete[] output;
}
But strlen is returning 16, where I would expect it to be 1 and 2.
newoperator does not guarantee the memory block's bytes will be _zero_ed.output = new char[i+1]();