Ask Your Question

Revision history [back]

Well, you have declared filename3 as follows:

filename3 = (char *)malloc(sizeof(char));

What you are doing there is to declare a pointer to a single char (and only one char). I guess that what you want is to allocate memory for a certain number of characters, not only one. Try something like this:

filename3 = (char *)malloc(sizeof(char)*APPROPIRATE_SIZE_FOR_FILENAME3);

Where APPROPRIATE_SIZE_FOR_FILENAME3 may be, for example, 1024. By doing this your file names will be allowed to be 1023 characters long.

Also, you didn't include the definition of img_db, but you might have the same problem there.

I hope this helps.