The Partridge Family were neither partridges nor a family. Discuss.
-
Clodi
- Posts: 175
- Joined: November 18th, 2012, 7:47 pm
Post
by Clodi » November 22nd, 2014, 5:59 pm
Code: Select all
Run-Time Check Failure #2 - Stack around the variable 'lattice' was corrupted.
Code: Select all
int main()
{
Site site;
return 0;
}
Code: Select all
class Site
{
private:
float position[ NDIMENSIONS ];
int neighbours[ NNEIGHBOURS ];
float neighboursPosition[ NNEIGHBOURS ][ NDIMENSIONS ];
public:
Site();
Site( float,float,float );
};
and
Code: Select all
Site::Site()
{
//initialise position
for( int i = 0; i < NDIMENSIONS; i++ ) { position[ i ] = 0.; }
//initialise neighbours
for( int i = 0; i < NNEIGHBOURS; i++ ) { neighbours[ i ] = NSITES; }
//initialise neighbours position
for( int i = 0; i < NNEIGHBOURS; i++ )
{
for( int j = 0; j < NDIMENSIONS + 1; j++ )
{
neighboursPosition[ i ][ j ] = 0.;
}
}
}
The program crashes sometimes, and sometimes it doesn't. When it does, it writes that above. It's the same error that has been around for so long, but because I was using CodeBlocks I had no idea what it was..
Any help would be greatly appreciated.
Thanks,
Clodi
-
Clodi
- Posts: 175
- Joined: November 18th, 2012, 7:47 pm
Post
by Clodi » November 22nd, 2014, 6:04 pm
the code breaks at the very end..
if I put a "cin >> a" type thing, the code will wait for me to enter a variable and then it will crash at the very end.
I tried adding a destructor and it didn't work.
-
LuisR14
- Posts: 1248
- Joined: May 23rd, 2013, 3:52 pm
- Location: USA
-
Contact:
Post
by LuisR14 » November 22nd, 2014, 6:21 pm
i think this is wrong
Code: Select all
for( int j = 0; j < NDIMENSIONS + 1; j++ )
don't you mean "j < NDIMENSIONS;" ?
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]
irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]
alt[/url] -- join up if ever want real-time help or to just
chat --
-
Clodi
- Posts: 175
- Joined: November 18th, 2012, 7:47 pm
Post
by Clodi » November 22nd, 2014, 9:15 pm
..! yes.. that's right. I had to add 1 at the very first stage, then I thought it would be confusing so I changed some of the code and forgot about that one 1 there.. grrrr
Thank you so much, Luis!
-
LuisR14
- Posts: 1248
- Joined: May 23rd, 2013, 3:52 pm
- Location: USA
-
Contact:
Post
by LuisR14 » November 22nd, 2014, 11:14 pm
haha, no prob xD
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]
irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]
alt[/url] -- join up if ever want real-time help or to just
chat --
-
BurakCanik
- Posts: 250
- Joined: February 8th, 2014, 9:16 pm
- Location: Istanbul, Turkey
Post
by BurakCanik » November 26th, 2014, 4:35 pm
Luis to the rescue as always
If real is what you can feel, smell, taste and see, then 'real' is simply electrical signals interpreted by your brain" - Morpheus