Click here to Skip to main content
15,888,271 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to find a file is already opened or not? Pin
Paulraj G27-May-10 23:37
Paulraj G27-May-10 23:37 
AnswerRe: How to find a file is already opened or not? Pin
Aescleal28-May-10 0:07
Aescleal28-May-10 0:07 
AnswerRe: How to find a file is already opened or not? Pin
Richard MacCutchan28-May-10 3:01
mveRichard MacCutchan28-May-10 3:01 
AnswerRe: How to find a file is already opened or not? Pin
Randor 28-May-10 4:07
professional Randor 28-May-10 4:07 
GeneralRe: How to find a file is already opened or not? Pin
Aescleal28-May-10 4:21
Aescleal28-May-10 4:21 
AnswerRe: How to find a file is already opened or not? Pin
ThatsAlok30-May-10 20:53
ThatsAlok30-May-10 20:53 
AnswerRe: How to find a file is already opened or not? Pin
rp_suman31-May-10 19:06
rp_suman31-May-10 19:06 
QuestionNot catching the exception Pin
gsainath4u27-May-10 22:27
gsainath4u27-May-10 22:27 
Hello All,

I have a code snippet as follows

struct ItemNode
{
    CString szID;
};

void DoSomething()
{
    ItemNode *a = NULL;    
    TRY {    
        CString s;    
        s.Format (_T("%s"), a->szID);    
    }    
    CATCH(CException b){    
        MessageBox (_T("Exception occured"));    
        b->Delete ();    
    }    
    END_CATCH    

    return;
}


Here, I am not able to catch the exception. The app crashes saying "There is an access violation.... "

What is the correct way to catch the exception??


I am using C++, MFC and the development is in VisualStudio 2005.
AnswerRe: Not catching the exception Pin
Code-o-mat27-May-10 22:31
Code-o-mat27-May-10 22:31 
GeneralRe: Not catching the exception PinPopular
sashoalm27-May-10 22:34
sashoalm27-May-10 22:34 
GeneralRe: Not catching the exception Pin
Code-o-mat27-May-10 22:41
Code-o-mat27-May-10 22:41 
GeneralRe: Not catching the exception Pin
gsainath4u27-May-10 22:51
gsainath4u27-May-10 22:51 
GeneralRe: Not catching the exception Pin
sashoalm27-May-10 23:21
sashoalm27-May-10 23:21 
GeneralRe: Not catching the exception Pin
Code-o-mat27-May-10 23:34
Code-o-mat27-May-10 23:34 
GeneralRe: Not catching the exception Pin
gsainath4u27-May-10 22:47
gsainath4u27-May-10 22:47 
GeneralRe: Not catching the exception Pin
Code-o-mat27-May-10 22:51
Code-o-mat27-May-10 22:51 
GeneralRe: Not catching the exception Pin
Aescleal27-May-10 23:04
Aescleal27-May-10 23:04 
GeneralRe: Not catching the exception Pin
gsainath4u28-May-10 0:01
gsainath4u28-May-10 0:01 
GeneralRe: Not catching the exception Pin
gsainath4u27-May-10 23:58
gsainath4u27-May-10 23:58 
GeneralRe: Not catching the exception Pin
Code-o-mat28-May-10 0:05
Code-o-mat28-May-10 0:05 
AnswerRe: Not catching the exception Pin
sashoalm27-May-10 22:33
sashoalm27-May-10 22:33 
GeneralRe: Not catching the exception Pin
Aescleal27-May-10 22:43
Aescleal27-May-10 22:43 
GeneralRe: Not catching the exception Pin
gsainath4u27-May-10 22:59
gsainath4u27-May-10 22:59 
AnswerRe: Not catching the exception Pin
Stephen Hewitt28-May-10 0:08
Stephen Hewitt28-May-10 0:08 
GeneralRe: Not catching the exception Pin
gsainath4u28-May-10 0:28
gsainath4u28-May-10 0:28 

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.