|
I am using VC++ V6. When running a program I am writing multiple times, I get a stack overflow error message. That is the program runs and exits okay but after a variable number of runs the error appears. Sometimes after a couple of runs and sometimes after 14 0r 15 runs.
The following code is pointed to after the message:
void CSudokuDlg::fnCheckForZeros()
{
ipRandomArrayPointer=&iRandomNumberArray[0];
for (iCount0=0;iCount0<9;iCount0++) //cks for zeros in random array
{
if(*ipRandomArrayPointer==0)
{
ipRandomArrayPointer++;
}
else break;
}
}
It is called from a function that can call itself, but the max number of calls should only be less than a hundred or so. If I put the function above in the calling function as part of it's code the problem still exists. The calling function is then pointed to after the error.The array is dimensioned at 9 so it's not being over run.
The calling function is:
void CSudokuDlg::fnDuplicateCheck()
{
for(iCount1=0;iCount1<iColumnEnd;iCount1++)
{
if(*ipChkSolArrayForDupes==*ipRandomArrayPointer)
{
if(bRlastRow==true)//This means the solution is not possible
{ //with this random number set
bFlag=true;
return;
}
ipRandomArrayPointer++;
if(*ipRandomArrayPointer==0) fnCheckForZeros();
ipChkSolArrayForDupes-=(iCount1);
fnDuplicateCheck();
}
ipChkSolArrayForDupes++;
}
bRlastRow=false;
}
The problem has not occurred when stepping through the program - only when the program is restarted.
Can anybody help?
|
|
|
|
|
What does the stack frame look like when the stack overflow message is shown?
Clay L wrote: for(iCount1=0;iCount1<iColumnEnd;iCount1++)
What is the value of iColumnEnd ?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
The problem is solved !!
I had not looked at the call stack thinking it would give me some assembly language locations that wouldn't help. I was amazed to see the actual names of the functions called in the stack display.
When the stack overflow occurred, the function "fnDuplicateCheck()" appeared to be in an endless loop. I had protected against that - I thought - and it would have worked if I had checked the correct flag.
When I made the change the problem was fixed.
There are some nifty trouble shooting things in V++6 – if you have the experience to use them.
Thank you David!
|
|
|
|
|
i have a part of syntax below:
CEdit* pEdit=(CEdit*)GetDlgItem(IDC_EDIT1);<br />
CString strTeks;<br />
pEdit->GetWindowText(strTeks);<br />
<br />
int nLineCount = pEdit->GetLineCount();<br />
CString strLine;<br />
for (i=0;i < nLineCount;i++)<br />
{<br />
int len = pEdit->LineLength(pEdit->LineIndex(i));<br />
pEdit->GetLine(i, strTeks.GetBuffer(len), len);<br />
strTeks.ReleaseBuffer(len);<br />
strLine.Format(TEXT("line %d: '%s'\n"), i, strTeks);<br />
} then i want to print every character in the edit box in term of "1"
and "0" using fprintf at a .txt file. How can i do that???
HelpMe
-- modified at 11:11 Thursday 30th March, 2006
|
|
|
|
|
A funny method to try: supposing strTks is a number in a string, convert it to a real int:
unsigned int nb=aoti(strTks.operator LPCTSTR());
And convert it into a binary:
CString str="";
while (nb>0)
{
str=(nb&1 ? "1" : "0")+str;
nb>>=1;
}
Then you can fprintf the str.
~RaGE();
-- modified at 11:53 Thursday 30th March, 2006
|
|
|
|
|
Rage wrote: unsigned int nb=aoti(strTks.operator LPCTSTR());
Why the mess?
unsigned int nb = atoi(strTks);
Rage wrote: nb>>1;
You do realize that this does nothing, other than create an endless loop, don't you? Perhaps you meant to use this instead:
nb >>= 1;
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Why the mess?
Because it does it anyway, so let's make it obvious.
DavidCrow wrote: You do realize that this does nothing, other than create an endless loop, don't you? Perhaps you meant to use this instead:
nb >>=1, correct.
~RaGE();
|
|
|
|
|
thanks i solved the problem...
HelpMe
|
|
|
|
|
beardy janggut wrote: then i want to print every character in the edit box in term of "1"
and "0" using fprintf at a .txt file. How can i do that???
This makes no sense. What exactly is it that you are trying to accomplish?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
How do i generate the printout Format Using VC++
Like pohonebill
Hi
|
|
|
|
|
rameshmahadevan wrote:
How do i generate the printout Format Using VC++
What is "the printout Format?"
rameshmahadevan wrote: Like pohonebill
What is a/the "pohonebill?"
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
If you are refering to how to use the print functions/spooler etc. Then here[^] is an excellent little tutorial for printing in non-MFC.
|
|
|
|
|
waldermort wrote:
If you are refering to how to use the print functions/spooler etc.
Which I wasn't.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
It's my job to make sense of people's bad English. It's starting to rub off on me now, My English was one of the best in Uni, now after teaching all this time I have come down to my student's level
|
|
|
|
|
I think you missed David's point which was (if I understood his post correctly) that HE wasn't referring to anything. He wasn't the one asking the question.
Of course, CodeProject often puts replies in the wrong place, so that could be why your reply to the original poster was attached to his reply.
((But I think I put my reply in the wrong place - it should have been in response to your second post in this thread! Ooops. ))
-- modified at 1:01 Friday 31st March, 2006
|
|
|
|
|
|
~RaGE();
|
|
|
|
|
finallyfinally
|
|
|
|
|
bang bang
|
|
|
|
|
"Sarah Connor ?"
~RaGE();
|
|
|
|
|
nop, rameshmahadevan... sorry
but it was the idea
|
|
|
|
|
|
Hello,
I would like to know, for joining two pixels in a bitmap.
As i have set of pixels, so i need to join them.
|
|
|
|
|
huh ?
pixels are independant entities ( if I may say so ); even in a bitmap.
what exactly are you wanting to do ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I have set of cartesian coordinates, i plotted them on bitmap by using SetPixel(...);,
and so then i would like to join all the pixels.
|
|
|
|