Simple CFile question
Posted on 2002-03-24
When reading a file, I want to pick up a string after a series of reads of different structures. However after reading in a string, the string that is read in contains garbage after it. So then I found that after I created a temp character pointer initialized to a size of one and then read it in, it seemed to read the string correctly however it wont let me delete the string after a loop:
for (y = 0; y < NUM_SAMPLES_ALLOWED; y++)
if (lengthOfFileNames[y] > 0)
//When the following is initialized to the actual
// size of the string to read, the string is
// retrieved but has garbage after it
// example: 'c:\myfiles\myfile.doc@@@@@@'
// Initializing it to 0 or 1 seems to work for some
// unknown reason.
tempName = new char;
filePaths[y] = tempName;
//It crashes if I include the following line:
//delete  tempName;
So now with this bizzare initialization of size 1 and a no delete line, it works but could someone tell me why??
Do I have a memory leak without that delete  tempName?