An access violation sounds like you're running out of bounds on your arrays. An access violation is you trying to access some block of memory you shouldn't be accessing.
Quzah.
An access violation sounds like you're running out of bounds on your arrays. An access violation is you trying to access some block of memory you shouldn't be accessing.
Quzah.
Hope is the first step on the road to disappointment.
I know, but I've checked and double checked it and can't seem to find any that are erranous, I've examined the entire variable 'g_table[x]' and all it's values are in bounds and as they should be; I've also compared sizeof(g_table[x]) with sizeof(TABLE) and these are identical.
Plus, I don't see how simply calling a function would produce this error; as far as I am aware there is no writing to my variable in the function call, except to pass the variable to the function (if that makes sense).
So I'm guessing that the error occurs in between the two lines of code:
Well, I don't really have a clue, I usually resolve Access Violations without much bother but this one has really got to me!Code:1. g_table[x] = MyFunction(g_table[x]); // error here? 2. TABLE MyFunction(TABLE table){...}
"The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns
Since your passing one of these by value, playerCode:typedef struct { PLAYER player[MAX_PLAYERS]; int pot, dButton, nPlayers, nActivePlayers; BLINDS blinds; BOOL visible; BOOL active; BOOL suspended; } TABLE;
gets copied as well. Try passing a TABLE*.
Yes, thats what I've done to fix it (it makes more sense anyway!).
Would copying 'player' neccessarily produce an error though, cos I checked each 'player' in the variable and they were all ok?
"The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns
I've heard of people getting segfaults doing stuft like
this with large arrays.
Oh cool, perhaps thats it, that kind of thing seems the only plausible reason to me; I take it a 'segfault' is to do with allocating/ copying memory?
"The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns
A segfault is when you access memory that your program
doesn't own.
Oh, sorry, gotcha (an access violation), I'm not to hot on terms of things!
Thanks for the help, I feel more at ease about using my structure now.
dt
"The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns
> When I used the Turbo debugger from Borland and stepped through the code
Mmmm....
I thought you were building a windows application
Which compiler are you using.
> The size of the struct is 7724
Ouch!
My guess is you've outgrown the stack in one easy step. Since you started with
TABLE PlaySeenHand(TABLE);
There would be two of these on the stack (one for the parameter, one for the return result).
> Mmmm....
> I thought you were building a windows application
I am, didn't realise that would be a problem! (I'm using debuggers for the first time and finding them very confusing). I'm using Dev-C++, I quite like the debugger with that but I couldn't get any error codes that I could find the meaning of so I tried the Turbo one and it seemed to work ok.
Brilliant, thanks, that seems to be the only thing that makes sense! I love bugs like this, you learn so much more trying to fix them!My guess is you've outgrown the stack in one easy step. Since you started with
TABLE PlaySeenHand(TABLE);
There would be two of these on the stack (one for the parameter, one for the return result).
dt
"The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns