Have a look at the line
ramkrishna.jangale wrote:
dbNames[i]=new char[strlen(imgFilename+1)];
Try to change it to
dbNames[i]=new char[strlen(imgFilename) + 1];
If
imgFilename
is a
char *
you move the pointer one char to the end and the result of
strlen()
is 1 byte less than the string length. So all allocated memory blocks for the filenames are two bytes too small, and not as needed one byte bigger for the tailing zero.