-
December 23rd, 2003, 06:58 AM
#1
weird problem in recursion
At the end of the recursion the program takes one step back normally and when trying to take the second step back it seems like it "doesnt know" where to go back to. (debuging showed that the failure is in the XSTRING file).
-
December 23rd, 2003, 07:39 AM
#2
the violationd is termed : access violation, if that helps. and just to clerify, the problem accurs in the last time that the funcion called itself, but coming back form the recursion.
-
December 23rd, 2003, 08:17 AM
#3
When the recursion returns you write something where you shouldn't, but without the code it's impossible to say what's wrong.
-
December 23rd, 2003, 08:33 AM
#4
else //num of bracks = 1;
{
while((finished ==0)&&(inFile))
{
if(!inFile.getline(buf, Max_Buf_Size)) break;
line = buf;
line = Make_Standard(line);
int index =0;
if (line.at(index) == '}')
{
if (index > 0)
{
if(make_Command(line.substr(0, line.size() - 2), new_Class))
{
if(is_in_if == 0)
{
if(is_in_while == 0)
{
Classes_of_Code->push_back(new_Class);
finished = 1;
} else {
std::cout << "error, unfinished while in code"<<std::endl;
inFile.close();
Fail = true;
}
}
else
{
std::cout << "error, unfinished if in code"<<std::endl;
inFile.close();
Fail = true;
}
}
else
{//error
inFile.close();
Fail = true;
}
}//index > 0
else
{
if (is_in_if ==0)
{
if(is_in_while ==0)
{
Classes_of_Code->push_back(new_Class));
finished = 1; /////////////////////2//////////////////
}
else
{
std::cout << "error, unfinished if in code"<<std::endl;
inFile.close();
Fail = true;
}
}
else
{
std::cout << "error, unfinished while in code"<<std::endl;
inFile.close();
Fail = true;
}
}
}
else
{
if(make_Command(line, new_Class))
{
Build_Class(new_Class, inFile, params, 1);/////////1////
}
else
{//error
inFile.close();
Fail = true;
}
}
}//while
}//else
}//Build_Class
thats the relavant code, the first part contains an if part that is not relevant. the class is named build_class and Build_command returns true in this case.
the line marked 2 (in the margins) is the end of the recursion, and the line marked 1 is the calling for the recursion, and also where the program last functions normally. i.e. when the recursion comes back first time, the program jumps from line 1 to the } of the end of the class (as should be) and then gets an access violation.
p.s. Build_class returns void.
the parameters of Build_Class are a pointer, an ifstream, a string and an int
Last edited by Avishay_b; December 23rd, 2003 at 08:38 AM.
-
December 23rd, 2003, 10:45 AM
#5
never mind, solved it.
thanks anyway.
-
December 23rd, 2003, 11:06 AM
#6
Originally posted by Avishay_b
never mind, solved it.
thanks anyway.
You see, it helped to post the code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|