In this section, we will see how to use the catch block for exception handling and the type conversion in C++. At first, let us see a code, and we will see what will be the output, and how they are generating. , , So, what is the reason behind this. Why this kind of output is generating? As we can see the character ‘a’ is thrown, but the first catch block is for int. If we think.....
Here we will see how to generate lexicographically next permutation of a string in C++. The lexicographically next permutation is basically the greater permutation. For example, the next of “ACB” will be “BAC”. In some cases, the lexicographically next permutation is not present, like “BBB” or “DCBA” etc. In C++ we can do it by using a library.....
Here we will see how to pass reference of some variable in C++. Sometimes we call it as “Call by Reference”. The call by reference method of passing arguments to a function copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect t.....
In this section, we will see how we can get the size of an integer array in C or C++? The size of int[] is basically counting the number of elements inside that array. To get this we can use the sizeof() operator. If the array name is passed inside the sizeof(), then it will return total size of memory blocks that are occupied by the array. Now if we divide it by the size of each element, t.....
In this section we will see how to see the Host name and IP address of the local system in an easier way. We will write a C program to find the host name and IP. Some of the following functions are used. These functions have a different task. Let us see the functions and their tasks. FunctionDescriptiongethostname()It finds the standard host name for the local computer.gethostbyname()It fin.....
In this section, we will see what are the setjump and longjump in C. The setjump() and longjump() is located at setjmp.h library. The syntax of these two functions is like below. , These are used in C for exception handling. The setjump() can be used as try block, and longjump() can be used as throw statement. The longjump() transfers control the pointe which is pointed by setjump(). Here w.....
Here we will see how to write one-line C function, that can round floating point numbers. To solve this problem, we have to follow these steps. Take the numberif the number is positive, then add 0.5Otherwise, subtract 0.5Convert the floating point value to an integer using typecasting, ,
The C library function int remove(const char *filename) deletes the given filename so that it is no longer accessible. Following is the declaration for remove() function. , This function takes the filename. This is the C string containing the name of the file to be deleted. On success, zero is returned. On error, -1 is returned, and errno is set appropriately. , Let us assume we have a.....
Here we will see what is the restrict keyword in C. The restrict keyword first introduced in C99 version. Let us see what is actually this restrict keyword. The restrict keyword is used for pointer declarations as a type quantifier of the pointer. This keyword does not add new functionalities. Using this the programmer can inform about an optimization that compiler can make. When the restri.....
Sign up now to get your own personalized profile!
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more