Click here to Skip to main content
16,006,440 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Array definition global vs local? Pin
John M. Drescher22-Jul-03 18:39
John M. Drescher22-Jul-03 18:39 
GeneralRe: Array definition global vs local? Pin
Alexander M.,23-Jul-03 1:30
Alexander M.,23-Jul-03 1:30 
GeneralRe: Array definition global vs local? Pin
John M. Drescher23-Jul-03 3:44
John M. Drescher23-Jul-03 3:44 
GeneralProblem Solved!! Pin
spaced_out22-Jul-03 18:05
spaced_out22-Jul-03 18:05 
GeneralRe: Problem Solved!! Pin
John M. Drescher22-Jul-03 18:36
John M. Drescher22-Jul-03 18:36 
GeneralRe: Problem Solved!! Pin
David Crow23-Jul-03 2:23
David Crow23-Jul-03 2:23 
GeneralRe: Problem Solved!! Pin
Alexander M.,23-Jul-03 1:30
Alexander M.,23-Jul-03 1:30 
GeneralRe: Problem Solved!! Pin
John M. Drescher24-Jul-03 7:25
John M. Drescher24-Jul-03 7:25 
I think the only reason why that solved your problem is that if you step past the end of a global variable you are probably not going to interfere with the runtime stack. Your problem probably still exists but in a sneaky way. Try the following declare your values array as
double ValuesArray[190];

Guess what it probably will not crash your dialog this time either. Why does it not crash the dialog? It is overwriting other variables in your global data that could come back and cause your program to work in an unexpected way.

I just tested my theory and it worked. I created a dialog application and in my OnOk() function I did the following which caused a crash because I am stepping past the end of ValuesArray.
void CStackOverflowDlg::OnOK() 
{
	double ValuesArray[200];
	for(int i=0;i < 300;i++) {
		ValuesArray[i] = 100.0;
	}
}

Guess what moving ValuesArray to the global namespace and there was no crash at all.
double ValuesArray[200];
void CStackOverflowDlg::OnOK() 
{
//	double ValuesArray[200];
	for(int i=0;i < 300;i++) {
		ValuesArray[i] = 100.0;
	}
}


But have I fixed the problem? Absolutely NOT! I still am using more items ValuesArray than I declared...


John
Generalassigning IP address dynamically Pin
pramodastro22-Jul-03 6:27
pramodastro22-Jul-03 6:27 
GeneralRe: assigning IP address dynamically Pin
valikac22-Jul-03 8:53
valikac22-Jul-03 8:53 
GeneralSpy++ for DirectX Pin
gordingin22-Jul-03 6:22
gordingin22-Jul-03 6:22 
GeneralRe: Spy++ for DirectX Pin
ZoogieZork22-Jul-03 8:35
ZoogieZork22-Jul-03 8:35 
GeneralNewb Pin
Derek1018822-Jul-03 5:58
Derek1018822-Jul-03 5:58 
GeneralRe: Newb Pin
Ian Darling22-Jul-03 6:38
Ian Darling22-Jul-03 6:38 
GeneralRe: Newb Pin
John M. Drescher22-Jul-03 7:43
John M. Drescher22-Jul-03 7:43 
GeneralRe: Newb Pin
Michael P Butler22-Jul-03 6:53
Michael P Butler22-Jul-03 6:53 
GeneralCheck buttons Pin
ppathan22-Jul-03 5:06
ppathan22-Jul-03 5:06 
GeneralRe: Check buttons Pin
melwyn22-Jul-03 5:12
melwyn22-Jul-03 5:12 
GeneralRe: Check buttons Pin
Iain Clarke, Warrior Programmer22-Jul-03 5:14
Iain Clarke, Warrior Programmer22-Jul-03 5:14 
GeneralRe: Check buttons Pin
ppathan22-Jul-03 6:12
ppathan22-Jul-03 6:12 
GeneralRe: Check buttons Pin
G. Steudtel22-Jul-03 8:17
G. Steudtel22-Jul-03 8:17 
GeneralRe: Check buttons Pin
David Crow22-Jul-03 9:06
David Crow22-Jul-03 9:06 
GeneralRe: Check buttons Pin
Iain Clarke, Warrior Programmer22-Jul-03 23:12
Iain Clarke, Warrior Programmer22-Jul-03 23:12 
GeneralRe: Check buttons Pin
Ben80522-Jul-03 10:31
Ben80522-Jul-03 10:31 
Generalinline function Pin
act_x22-Jul-03 4:44
act_x22-Jul-03 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.