Connecting Tech Pros Worldwide Forums | Help | Site Map

strange behaviour of code.....

Member
 
Join Date: Jun 2007
Posts: 59
#1: Sep 24 '07
Hi, I am using Borland C++ Builder 5.0. We have a working code, but when we try to make some changes in it, it starts giving error. This happens in one file only. If change is in any other file, it runs smooth. The code doesn't uses any such file or library at runtime which can make effect in this manner.
Even if we add -- int i = 0; --- in a function which is not called until we select some option from the GUI, the code's flow is disrupted even before the GUI is generated. Every time the problem is at function where form is being created.
Any guess what could be the reason?

Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,180
#2: Sep 24 '07

re: strange behaviour of code.....


You are invoking undefined behaviour in some way. I would guess most probably that somewhere in you ode you are writing to an unitialised pointer or writing outside the bounds of an array.
Member
 
Join Date: Jun 2007
Posts: 59
#3: Sep 26 '07

re: strange behaviour of code.....


@Banfa
No Sir, I checked it out, but it is nothing like that. You add just one line in any function in a particular file, and the code doesn't run properly.
Even int i; doesn't let it work.
Member
 
Join Date: Jun 2007
Posts: 59
#4: Sep 26 '07

re: strange behaviour of code.....


It is giving invalid scope at some point, and is not going on a sprintf loc.
Member
 
Join Date: Jun 2007
Posts: 59
#5: Sep 26 '07

re: strange behaviour of code.....


sorry, its not invalid scope, it is inactive scope. And it comes at a for loop,
for(n = 0; n <= (int)Plot->PlotNo; n++)
{
sprintf(temps, "%d", n + 1);
PlotBox->Items->Add(temps);
}

The control doesn't goes to the sprintf line and gives inactive scope there.
Reply