Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

Why return do not terminate function in MS C2008 ++ ?

 Hi experts!

I'm new to MS C++ 2008 and need little help. I read in manual that return should break current execituon of the function, but after I finish my project by accident I find that look that is not true. Look my code:


long CCPlayCtrl::SetToZeroRemainTimeCurrFile(long lCard)
{
//  ... code

   if (!bFind)
          return -98; //Here should exit from function?!? Why do not exit and contunie with next code???


// next code write a message to the text file. I was shocked to find that bFind=false, return -98 is executed and function execution  just contunie with next row of code. WHY ???
         if (mbWriteAllCmd[lCard])
        {
             sLog.Format( _T( "CCPlayCtrl::SetToZeroRemainTimeCurrFile-->bFind=false !!!\n" ));
                                  StradisLogFunction(sLog);
        }


            lStradisDecoderSettingsFrame[iIndex]=0; lStradisDecoderSettingshWng[iIndex]=0;
            return 0;
 


 
}

Do i need to change all situations like this in my code, or this is some specific case? In any case I should know what is going on. To be more clear, this is ActiveX project (OCX) and this is one of his public functions.
0
dvplayltd
Asked:
dvplayltd
2 Solutions
 
jkrCommented:
Well, apparently 'bFind' does not seem to be 'false' - can you double check that? I know it's kinda stupid, but otherwise, the whoe thing should work.
0
 
Infinity08Commented:
>> I was shocked to find that bFind=false

I just see a string literal stating that bFind is false.
I don't see an actual check for that.


>>    if (!bFind)
>>           return -98; //Here should exit from function?!? Why do not exit and contunie with next code???

If the function didn't return there, it means that bFind was true at that point ... Try following what happens with bFind to get a better idea of what's going on.
0
 
dvplayltdAuthor Commented:
10x. In final case you are right, bFind is not false, sorry for stuped question.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now