I've created a program that reads lines from the text file. Each line is parsed to find a command and parameters that are executed. So, the essential code goes something like this:
while (getline(script, scriptline))
Parse Scriptline
Execture Scriptline Function
This works very well for most functions. Until I get to one that creates and writes to several files. That function operates just fine, but when it ends and control returns to the above loop, scriptline is read but sometimes no longer contains a full line of data. I've had situations where it should have read a line that looks like this:
FunctionalAlignment3, Tal-Cal, XYZ, base
but somehow read it so that it looked like this:
Functiona Tal-Cal, XYZ, base
For some reason, it just skips over the central part of the text line and seems to replace its content with spaces.
This only occurs when the script calls a function that creates and writes to five separate files. That function creates, opens and closes each file in turn. So, at best, only two files are open at one time (the file that contains the scriptline and the new file that is being created).
I've tried my scriptloop to read the next line (adding an additional getline to skip over the one with the problem) and that line seems to read just fine (at least so far). So, I've tried rewriting the scipt, in case some type of control character got into my text on the problem line. That did not help.
I should also point out that the function in question works sometimes. I can create a script that contains the same lines five times. It runs properly for three and then only partially reads the fouth line of the script.
I thought this might be a memory leak problem in the function that is called by the script. I've made sure that for every use of the word "new" there is a use of the word "delete". So, if it is a memory leak, I do not know how to find it.
So, any suggestions about what may be going wrong here?
Suggestions on where to look for possible solutions would be welcome also.
Thanks.