Click here to Skip to main content
14,209,847 members

C / C++ / MFC

 
SuggestionRe: i would like to be a programmer Pin
David Crow29-May-18 8:31
memberDavid Crow29-May-18 8:31 
AnswerRe: i would like to be a programmer Pin
Victor Nijegorodov29-May-18 9:27
memberVictor Nijegorodov29-May-18 9:27 
AnswerRe: i would like to be a programmer Pin
CPallini29-May-18 23:01
mveCPallini29-May-18 23:01 
AnswerRe: i would like to be a programmer Pin
jfbode102930-May-18 4:33
memberjfbode102930-May-18 4:33 
AnswerRe: i would like to be a programmer Pin
Vaclav_30-May-18 9:19
memberVaclav_30-May-18 9:19 
AnswerRe: i would like to be a programmer Pin
Tarun Jha5-Jun-18 10:53
memberTarun Jha5-Jun-18 10:53 
Questiontry /catch Exception missing type Pin
Vaclav_29-May-18 4:00
memberVaclav_29-May-18 4:00 
AnswerRe: try /catch Exception missing type Pin
Jochen Arndt29-May-18 5:09
mveJochen Arndt29-May-18 5:09 
Before using a feature you should know about it:
Exceptions - C++ Tutorials

Then you should realise that catching exceptions makes only sense when functions called inside the try block might throw them. But C standard library functions like perror() do not throw them (because it is a C++ feature, the C standard does not define them).

Finally you have to know which kind of exceptions (types) might be thrown. Implement a catch block for each of them. With functions from the C++ standard library, these are std::exception - cppreference.com[^] and derived ones.

An example:
#include <exception>

std::ifstream file;
// Enable throwing of exceptions for file
file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
try
{
    // Calling C++ functions here that might throw exceptions

    file.open("test.txt");
    // Do something with file here
    file.close();
}
catch (std::exception& e)
{
    cout << e.what() << '\n';
}

AnswerRe: try /catch Exception missing type Pin
Richard MacCutchan29-May-18 5:12
protectorRichard MacCutchan29-May-18 5:12 
AnswerRe: try /catch Exception missing type SOLVED Pin
Vaclav_30-May-18 9:06
memberVaclav_30-May-18 9:06 
GeneralRe: try /catch Exception missing type SOLVED Pin
leon de boer30-May-18 16:25
memberleon de boer30-May-18 16:25 
Questionhow to correct an segmentation fault ? Pin
Tarun Jha26-May-18 11:55
memberTarun Jha26-May-18 11:55 
SuggestionRe: how to correct an segmentation fault ? Pin
Richard MacCutchan26-May-18 21:10
protectorRichard MacCutchan26-May-18 21:10 
AnswerRe: how to correct an segmentation fault ? Pin
CPallini29-May-18 0:01
mveCPallini29-May-18 0:01 
GeneralRe: how to correct an segmentation fault ? Pin
Tarun Jha5-Jun-18 1:50
memberTarun Jha5-Jun-18 1:50 
QuestionGraphical representation of Data Pin
sree7926-May-18 1:09
membersree7926-May-18 1:09 
AnswerRe: Graphical representation of Data Pin
Richard MacCutchan26-May-18 2:41
protectorRichard MacCutchan26-May-18 2:41 
GeneralMessage Closed Pin
26-May-18 6:24
memberben lewis26-May-18 6:24 
GeneralMessage Closed Pin
26-May-18 6:26
memberben lewis26-May-18 6:26 
AnswerRe: Graphical representation of Data Pin
leon de boer26-May-18 5:09
memberleon de boer26-May-18 5:09 
GeneralRe: Graphical representation of Data Pin
sree7927-May-18 17:44
membersree7927-May-18 17:44 
Questionvolatile issue - repost Pin
Vaclav_22-May-18 5:24
memberVaclav_22-May-18 5:24 
QuestionRe: volatile issue - repost Pin
Richard MacCutchan22-May-18 8:26
protectorRichard MacCutchan22-May-18 8:26 
AnswerRe: volatile issue - repost Pin
CPallini22-May-18 10:11
mveCPallini22-May-18 10:11 
AnswerRe: volatile issue - repost Pin
leon de boer22-May-18 19:12
memberleon de boer22-May-18 19:12 

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.


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190617.3 | Last Updated 18 Jun 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid