Hello . I'm experiencing a really weird bug that's been plaguing me throughout the development of my program - some of my variables (even ones that are not referenced anywhere except my debug segment) are having their values overwritten when I declare other variables.

Here's a very clear and simple example excerpt from my code.

int newvariable = 5;
cout<<newvariable; //prints 5
int anothernewvariable = 3;
cout<<newvariable; //prints 3

Its current manifestation is wreaking havoc on one of my arrays, setting what should be default 0 values to huge integers and negative numbers at random. Furthermore, I can't write 0 over the new integers without my program crashing. Does anyone have any idea what could be causing this? If you need I'll be glad to post the whole project up, but I'm starting off with this tentative excerpt post to see if anyone knows the culprit right off the bat. Thanks in advance, and I hope this is interesting for you all and worth posting .