Found 7346 Articles for C++

What all is inherited from parent class in C++?

Samual Sam
Updated on 26-Jun-2020 08:14:35

3K+ Views

In the object-oriented programming, we can inherit the characteristics of parent class. Parent class is known as base class while child class is known as derived class. The derived class can inherit data members, member functions of base class.If the data members are public, they can be accessed by derived class, same class and outside the class. If data members are protected, they can be accessed by derived and same class only, but outside the class, they can not be accessed. If data members are private, only same class can access them.Here is an example of inheritance in C++ language, ... Read More

(limits.h) in C/C++

Samual Sam
Updated on 26-Jun-2020 08:16:40

946 Views

The header files “limits.h” exists in C language while in C++ language. Several macros are defined in these header files. The limits specify that variable cannot store values beyond the limits.Some macros in “limits.h” or header file are as followsCHAR_BITLONG_MINLONG_MAXCHAR_MINCHAR_MAXINT_MININT_MAXSHRT_MINSHRT_MAXULONG_MAXHere is an example of in C++ language,Example Live Demo#include #include #include using namespace std; int main() {    int x = 28;    int a = CHAR_BIT*sizeof(x);    stack s;    cout

How to clear console in C?

Samual Sam
Updated on 26-Jun-2020 08:18:37

19K+ Views

There are several methods to clear the console or output screen and one of them is clrscr() function. It clears the screen as function invokes. It is declared in “conio.h” header file. There are some other methods too like system(“cls”) and system(“clear”) and these are declared in “stdlib.h” header file.Here is the syntax to clear the console in C language, clrscr(); OR system(“cls”); OR system(“clear”);Here is an example to clear the console in C language, Let’s say we have “new.txt” file with the following content −0, hell!o 1, hello! 2, gfdtrhtrhrt 3, demoNow, let us see the example.Example#include #include void ... Read More

mbrlen() function in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 08:19:06

134 Views

The function mbrlen() is used to get the length of multibyte character. It returns the size of multibyte character pointed by the pointer.Here is the syntax of mbrlen() in C language, size_t mbrlen(const char* pointer, size_t size, mbstate_t* state);Here, pointer − Pointer to the first byte of multibyte character.size − Number of bytes to check.state − Pointer to the object of mbstate_tHere is an example of mbrlen() in C language, Example Live Demo#include #include #include int main(void) {    char a[] = "s";    mbstate_t s;    int len;    len = mbrlen(a, 5, &s);    printf("Length of ... Read More

raise() function in C/C++

Samual Sam
Updated on 26-Jun-2020 08:05:21

306 Views

The function raise() is used to send the signals to the program. The predefined function signal() is invoked. It is implemented to check whether it will ignore the signal or invoke the signal handler. This is declared in “signal.h” header file. It returns zero, if successful otherwise, non-zero value.Here is the syntax of raise() in C language, int raise(int signal)Here, signal − The signal number to be invoked.Here is an example of raise() in C language, Example Live Demo#include #include void handler(int sig) {    printf("Signal received : %d", sig); } int main() {    signal(SIGILL, handler);    printf("Sending ... Read More

atexit() function in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 08:05:54

310 Views

The function atexit() is used to call the function after the normal exit of program. The program is called without any parameters. The function atexit() is called after exit(). The termination function can be called anywhere in the program. This function is declared in “stdlib.h” header file.Here is the syntax of atexit() in C language, int atexit(void (*function_name)(void))Here, function_name − The function is to be called at the time of termination of program.Here is an example of atexit() in C language, Example Live Demo#include #include void func1 (void) {    printf("Exit of function 1"); } void func2 (void) { ... Read More

ungetc() in C/C++

Samual Sam
Updated on 26-Jun-2020 08:06:26

181 Views

The function ungetc() takes a character and pushes it back to the stream so that the character could be read again.Here is the syntax of ungetc() in C language, int ungetc(int character, FILE *stream)Here, character − The character to be pushed back to stream.stream − The pointer to the file object.Here is an example of ungetc() in C language, Example#include int main() {    int c;    while ((c = getchar()) != '0')    putchar(c);    ungetc(c, stdin);    c = getchar();    putchar(c);    puts("");    printf("The End!");    return 0; }Outputs a b c t h 0 ... Read More

memcpy() function in C/C++

Samual Sam
Updated on 26-Jun-2020 08:08:37

5K+ Views

The function memcpy() is used to copy a memory block from one location to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language. It does not check overflow.Here is the syntax of memcpy() in C language, void *memcpy(void *dest_str, const void *src_str, size_t number)Here, dest_str − Pointer to the destination array.src_str − Pointer to the source array.number − The number of bytes to be copied from source to destination.Here is an example of memcpy() in C language, Example Live Demo#include #include int main () {   ... Read More

memmove() function in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 08:09:03

374 Views

The function memmove() is used to move the whole memory block from one position to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language.Here is the syntax of memmove() in C language, void *memmove(void *dest_str, const void *src_str, size_t number)Here, dest_str − Pointer to the destination array.src_str − Pointer to the source array.number − The number of bytes to be copied from source to destination.Here is an example of memmove() in C language, Example Live Demo#include #include int main () {    char a[] = "Firststring"; ... Read More

How can I convert string to double in C/C++?

Samual Sam
Updated on 26-Jun-2020 08:09:32

820 Views

Here is an example to convert a string to double.Example Live Demo#include using namespace std; int main() {    char s[20] = "18.2894 is a number";    char *p;    double result;    result = strtod(s, &p);    cout

Advertisements