Found 7346 Articles for C++

What is the size of void pointer in C/C++?

karthikeya Boyini
Updated on 26-Jun-2020 07:42:28

7K+ Views

The size of void pointer varies system to system. If the system is 16-bit, size of void pointer is 2 bytes. If the system is 32-bit, size of void pointer is 4 bytes. If the system is 64-bit, size of void pointer is 8 bytes.Here is an example to find the size of void pointer in C language, Example Live Demo#include int main() {    void *ptr;    printf("The size of pointer value : %d", sizeof(ptr));    return 0; }OutputThe size of pointer value : 8In the above example, a void type pointer variable is created and by using sizeof() ... Read More

delete() and free() in C++

Samual Sam
Updated on 26-Jun-2020 07:44:07

1K+ Views

delete()The delete operator is used to deallocate the memory. User has privilege to deallocate the created pointer variable by this delete operator.Here is the syntax of delete operator in C++ language,delete pointer_variable;Here is the syntax to delete the block of allocated memory,delete[ ] pointer_variable;Here is an example of delete operator in C++ language,Example Live Demo#include using namespace std; int main () {    int *ptr1 = NULL;    ptr1 = new int;    float *ptr2 = new float(299.121);    int *ptr3 = new int[28];    *ptr1 = 28;    cout

malloc() vs new() in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 07:45:24

5K+ Views

malloc()The function malloc() is used to allocate the requested size of bytes and it returns a pointer to the first byte of allocated memory. It returns null pointer, if fails.Here is the syntax of malloc() in C++ language, pointer_name = (cast-type*) malloc(size);Here, pointer_name − Any name given to the pointer.cast-type − The datatype in which you want to cast the allocated memory by malloc().size − Size of allocated memory in bytes.Here is an example of malloc() in C language, Example Live Demo#include #include int main() {    int n = 4, i, *p, s = 0;    p = ... Read More

What should main() return in C/C++?

karthikeya Boyini
Updated on 26-Jun-2020 07:46:45

5K+ Views

The return value of main() function shows how the program exited. The normal exit of program is represented by zero return value. If the code has errors, fault etc., it will be terminated by non-zero value.In C++ language, the main() function can be left without return value. By default, it will return zero.Here is the syntax of main() function in C language, int main() {    ….    return 0; }Here is an example of main() function in C language, Example Live Demo#include int main() {    int a = 10;    char b = 'S';    float c = ... Read More

The Best C++ Code Formatter/Beautifier?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

632 Views

There are so many C++ code formatter or beautifier tools which beautifies your code or format with proper indentation. The C++ code formatter/ beautifier are listed as follows − C++ Code Formatter/Beautifier Description Astyle This is a source code formatter. It can be used for C++, java and other languages. It’s latest version is 2.03 and it released in April 2013. Clang-Format It is a command line tool along with clang compiler. It is open- source tool and programmed in C++, python. The latest version is 3.3. Universal Indent GUI It ... Read More

The Best C++ IDE or Editor for Windows

Samual Sam
Updated on 30-Jul-2019 22:30:23

217 Views

The following are some of C++ IDEs for Windows. 1.Eclipse Galileo with CDT Plugin Eclipse is a well-known open source and cross platform IDE. It provides full functional C/C++ IDE with the following features − Code editor with support for syntax highlighting Support for folding and hyperlink navigation Source code refactoring plus code generation Tools for visual debugging such as memory, registers 2.NetBeans NetBeans is free, open source and popular IDE for C/C++. There are some following features − Support for automatic packaging of compiled application into .tar, .zip. Support for multiple compilers such as GNU, Clang/LLVM, ... Read More

modf() in C/C++

Samual Sam
Updated on 26-Jun-2020 07:35:27

298 Views

The function modf() is used to split the passed argument in integer and fraction. It is declared in “math.h” header file for the mathematical calculations. It returns the fractional value of passed argument.Here is the syntax of modf() in C language, double modf(double value, double *integral_pointer);Here, value − The value which splits into integer and fraction.integral_pointer − It points the integer part of argument after splitting.Here is an example of modf() in C language, Example Live Demo#include #include int main () {    double val, x, res;    val = 28.856;    res = modf(val, &x);    printf("Integral part of val ... Read More

isgreater() in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 07:35:55

210 Views

The function isgreater() is used to check that the first argument is greater than the second one or not. It is declared in “math.h” header file in C language. It returns true, if successful, otherwise false.Here is the syntax of isgreater().bool isgreater(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 that is greater or not.Here is an example of isgreater().Example Live Demo#include #include using namespace std; int main() {    int val1 = 28;    int val2 = 8;    bool result; ... Read More

When to use i++ or ++i in C++?

Samual Sam
Updated on 26-Jun-2020 07:36:30

1K+ Views

Increment operators are used to increase the value by one while decrement works opposite. Decrement operator decrease the value by one.Pre-increment (++i) − Before assigning the value to a variable, the value is incremented by one.Post-increment (i++) − After assigning the value to a variable, the value is incremented.Here is the syntax of i++ and ++i in C++ language,++variable_name; // Pre-increment variable_name++; // Post-incrementHere,variable_name −Name of the variable given by user.Here is an example of pre and post increment in C++ language,Example Live Demo#include using namespace std; int main() {    int i = 5;    cout

New Features of C++17

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

373 Views

C++17 is the latest version of standard C++ language. C++11 and C++14 are the previous versions of C++. The current version makes several additions to the core language while some previous features are also removed. C++17 is known as feature full or feature complete. There are some of the new changes introduced in C++17 − Library changes - utils This is one of the most amazing feature of C++17. It merges the features and patterns of other libraries. Many of the sub-libraries are merged together into standards. The following features are added to utils library in C++17 − std::variant ... Read More

Advertisements