Click here to Skip to main content
15,890,123 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
SuggestionRe: i would like to be a programmer Pin
David Crow29-May-18 8:31
David Crow29-May-18 8:31 
AnswerRe: i would like to be a programmer Pin
Victor Nijegorodov29-May-18 9:27
Victor 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
jfbode102930-May-18 4:33 
AnswerRe: i would like to be a programmer Pin
Vaclav_30-May-18 9:19
Vaclav_30-May-18 9:19 
AnswerRe: i would like to be a programmer Pin
Tarun Jha5-Jun-18 10:53
Tarun Jha5-Jun-18 10:53 
Questiontry /catch Exception missing type Pin
Vaclav_29-May-18 4:00
Vaclav_29-May-18 4:00 
AnswerRe: try /catch Exception missing type Pin
Jochen Arndt29-May-18 5:09
professionalJochen 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:
C++
#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
mveRichard MacCutchan29-May-18 5:12 
AnswerRe: try /catch Exception missing type SOLVED Pin
Vaclav_30-May-18 9:06
Vaclav_30-May-18 9:06 
GeneralRe: try /catch Exception missing type SOLVED Pin
leon de boer30-May-18 16:25
leon de boer30-May-18 16:25 
Questionhow to correct an segmentation fault ? Pin
Tarun Jha26-May-18 11:55
Tarun Jha26-May-18 11:55 
SuggestionRe: how to correct an segmentation fault ? Pin
Richard MacCutchan26-May-18 21:10
mveRichard 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
Tarun Jha5-Jun-18 1:50 
QuestionGraphical representation of Data Pin
sree7926-May-18 1:09
sree7926-May-18 1:09 
AnswerRe: Graphical representation of Data Pin
Richard MacCutchan26-May-18 2:41
mveRichard MacCutchan26-May-18 2:41 
AnswerRe: Graphical representation of Data Pin
leon de boer26-May-18 5:09
leon de boer26-May-18 5:09 
GeneralRe: Graphical representation of Data Pin
sree7927-May-18 17:44
sree7927-May-18 17:44 
Questionvolatile issue - repost Pin
Vaclav_22-May-18 5:24
Vaclav_22-May-18 5:24 
QuestionRe: volatile issue - repost Pin
Richard MacCutchan22-May-18 8:26
mveRichard 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
leon de boer22-May-18 19:12 
GeneralRe: volatile issue - repost Pin
CPallini22-May-18 21:39
mveCPallini22-May-18 21:39 
QuestionRe: volatile issue - repost Pin
CPallini22-May-18 10:11
mveCPallini22-May-18 10:11 

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.