Errors and Exceptions

commandline session

$gcc error.c
$cat error.c
#include

main()
{
int a=0;
int b=10;
printf("Hello Alln");
printf("%d",b/a);
}

$./a.out > outputa
Floating point exception
$cat outputa
$
$./a.out 2> outputa
Hello All
Floating point exception
$./a.out > outputa
Floating point exception
$./a.out 2> outputb
Hello All
Floating point exception
$./a.out &> outputc
Floating point exception
$cat outputa
$
$cat outputb
$cat outputc
$

An Error “indicates serious problems that a reasonable application should not try to catch.

An Exception “indicates conditions that a reasonable application might want to catch.

source : http://stackoverflow.com/questions/5813614/what-is-difference-between-errors-and-exceptions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s