raise() function in C++ Last Updated : 18 Aug, 2018 Comments Improve Suggest changes Like Article Like Report csignal header file declared the function raise() to handle a particular signal. Signal learns some unusual behavior in a program, and calls the signal handler. It is implemented to check if the default handler will get called or it will be ignored. Syntax: int raise ( int signal_ ) Parameter: The function accepts a single parameter sig which specifies the signal which is artificially raised. It can take any of the 6 C standard signals. Defined Signal Types SIGILL SIGINT SIGSEGV SIGTERM SIGABRT SIGFPE Return Value: It return a nonzero value with no error in signal else it returns zero. The function returns different nonzero elements with different defined signals. Below programs illustrate the above method: Program 1: CPP // C++ program to illustrate the // raise() function when SIGABRT is passed #include <csignal> #include <iostream> using namespace std; sig_atomic_t s_value = 0; void handle(int signal_) { s_value = signal_; } int main() { signal(SIGABRT, handle); cout << "Before called Signal = " << s_value << endl; raise(SIGABRT); cout << "After called Signal = " << s_value << endl; return 0; } Output: Before called Signal = 0 After called Signal = 6 Program 2: CPP // C++ program to illustrate the // raise() function when SIGINT is passed #include <csignal> #include <iostream> using namespace std; sig_atomic_t s_value = 0; void handle(int signal_) { s_value = signal_; } int main() { signal(SIGINT, handle); cout << "Before called Signal = " << s_value << endl; raise(SIGINT); cout << "After called Signal = " << s_value << endl; return 0; } Output: Before called Signal = 0 After called Signal = 2 Program 3: CPP // C++ program to illustrate the // raise() function when SIGTERM is passed #include <csignal> #include <iostream> using namespace std; sig_atomic_t s_value = 0; void handle(int signal_) { s_value = signal_; } int main() { signal(SIGTERM, handle); cout << "Before called Signal = " << s_value << endl; raise(SIGTERM); cout << "After called Signal = " << s_value << endl; return 0; } Output: Before called Signal = 0 After called Signal = 15 Program 4: CPP // C++ program to illustrate the // raise() function when SIGSEGV is passed #include <csignal> #include <iostream> using namespace std; sig_atomic_t s_value = 0; void handle(int signal_) { s_value = signal_; } int main() { signal(SIGSEGV, handle); cout << "Before called Signal = " << s_value << endl; raise(SIGSEGV); cout << "After called Signal = " << s_value << endl; return 0; } Output: Before called Signal = 0 After called Signal = 11 Program 5: CPP // C++ program to illustrate the // raise() function when SIGFPE is passed #include <csignal> #include <iostream> using namespace std; sig_atomic_t s_value = 0; void handle(int signal_) { s_value = signal_; } int main() { signal(SIGFPE, handle); cout << "Before called Signal = " << s_value << endl; raise(SIGFPE); cout << "After called Signal = " << s_value << endl; return 0; } Output: Before called Signal = 0 After called Signal = 8 Comment More infoAdvertise with us Next Article raise() function in C++ A AmanSrivastava1 Follow Improve Article Tags : Misc C Language C++ CPP-Library C-Library +1 More Practice Tags : CPPMisc Similar Reads std::function in C++ The std::function() in C++ is a function wrapper class which can store and call any function or a callable object. In this article, we will learn about std::function in C++ and how to use it in different cases.Table of ContentWhat is std::function in C++?Example of std::functionMember Functions of s 5 min read Function Pointer in C++ Prerequisites: Pointers in C++Function in C++ Pointers are symbolic representations of addresses. They enable programs to simulate call-by-reference as well as to create and manipulate dynamic data structures. Iterating over elements in arrays or other data structures is one of the main use of point 4 min read Inline Functions in C++ In C++, inline functions provide a way to optimize the performance of the program by reducing the overhead related to a function call. When a function is specified as inline the whole code of the inline function is inserted or substituted at the point of its call during the compilation instead of us 6 min read Function Pointer in C In C, a function pointer is a type of pointer that stores the address of a function, allowing functions to be passed as arguments and invoked dynamically. It is useful in techniques such as callback functions, event-driven programs, and polymorphism (a concept where a function or operator behaves di 6 min read Functions in C++ A function is a building block of C++ programs that contains a set of statements which are executed when the functions is called. It can take some input data, performs the given task, and return some result. A function can be called from anywhere in the program and any number of times increasing the 9 min read log() Function in C++ The std::log() in C++ is a built-in function that is used to calculate the natural logarithm (base e) of a given number. The number can be of any data type i.e. int, double, float, long long. It is defined inside the <cmath> header file.In this article we will learn about how to use std::log() 1 min read scalbn() function in C++ The scalbn() function is defined in the cmath header file. This function is used to calculate the product of given number x and FLT_RADIX raised to the power n. Syntax:- float scalbn(float x, int n); or double scalbn(double x, int n); or long double scalbn(long double x, int n); or double scalbn(int 2 min read tolower() Function in C++ The C++ tolower() function converts an uppercase alphabet to a lowercase alphabet. It is a predefined function of ctype.h header file. If the character passed is an uppercase alphabet, then the tolower() function converts an uppercase alphabet to a lowercase alphabet. This function does not affect a 2 min read C Functions A function in C is a set of statements that, when called, perform some specific tasks. It is the basic building block of a C program that provides modularity and code reusability. They are also called subroutines or procedures in other languages.Function DefinitionA function definition informs the c 6 min read fma() function in C++ The fma() function takes three arguments a, b and c, and returns a*b+c without losing precision. The fma() function is defined in the cmath header file. If any argument passed to fma() is long double, the return type is long double. If not, the return type is double. Syntax: double fma(double a, dou 2 min read Like