Honestly speaking, I have already completed writing the program of more than 500 lines. I am, thus, feeling lazy to either edit it massively or write another one unless I have no alternative simpler solution. That is the only reason, I am avoiding vectors in this program.
Regarding the error:
I am actually writing the program in Raspbian with a simple text editor. I do not have any debugging tool (nor do I know any without IDE).
I am simply asking the program to display something after every process. The line at which it stops displaying, is the error point (if I understand it right).
With this strategy, I found out that the program ends at the line where I delete Sptr.
1 2 3 4 5 6 7
|
cout<<"15\t";
delete [] Sptr;
cout<<"14\t";
|
The output of the above code is
Even more weird issue is that, the error keeps changing everytime.
For eg.
*** error in ./my_prog: double-free or corruption (!prev): 0x005c0308 ***
or
*** error in ./my_prog: corruption double-linked list
or some malloc error saying invalid pointer
or terminates abruptly without any error
This can happen after random number of cycles (1 or 2 or 3 or ...)