Are you saying that, with the same input, your program sometimes works and sometimes doesn't? Very odd. Try hard-coding your strings rather than reading from file.
Also, there is no need to mix strings and c-strings - just use the .size() member function to get the relevant lengths.
Why do you think it is a "memory leak"? Out-of-bounds array access, perhaps, but that's not the same thing. You could also use vectors of vectors instead of multi-dimensional dynamic arrays. There are then means of checking array bounds on access.
Well, as suggested in my earlier reply I changed the following:
- changed slen on lines 42 and 43 to tlen;
- changed tlen on line 45 to slen;
- added header <cstring>;
- commented out system("pause") - it's a bit irrelevant from the command line;
I put "Saturday" (without quotes) in s1, "Sunday" (without quotes) in s2 and ran my executable temp.exe as:
This gives the following output ... every time ... as
s1
s2
Saturday
Sunday
0 1 2 3 4 5 6 7 8
1 0 1 2 3 4 5 6 7
2 1 1 2 2 3 4 5 6
3 2 2 2 3 3 4 5 6
4 3 3 3 3 4 3 4 5
5 4 3 4 4 4 4 3 4
6 5 4 4 5 5 5 4 3 |
So I can't explain what you are having problems with.
BTW, a "breakpoint" is something you set and I suspect you meant something else. The same with "memory leak".
Also, if you are going to create a matrix to carry out this analysis, then your 1-d strings (human RNA!) had better not be too long.