Revathi Satya Kondra

Revathi Satya Kondra

Technical Content Writer, Tutorialspoint

65 Articles Published

Articles by Revathi Satya Kondra

Page 2 of 7

How does “void *” differ in C and C++?

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 10-Jun-2025 716 Views

Both languages (C and C++) support void pointers, but their behaviour is different. In C, a void pointer can be directly assigned to any other pointer type without the need for a typecast. However, in C++, assigning a void pointer to any other pointe type require an explicit typecast. In this article, we will learn the differences between void pointers in C and C++.. Void Pointer in C A void pointer (also called a generic pointer) in C is a special type of pointer that can point to any data type, but doesn’t have any type by itself. It ...

Read More

Wide char and library functions in C++

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 10-Jun-2025 4K+ Views

Wide Characters Wide characters are similar to character datatype. The main difference is that char takes 1-byte space, but wide character takes 2-bytes (sometimes 4-byte depending on compiler) of space in memory. For 2-byte space wide character can hold 64K (65536) different characters. So the wide char can hold UNICODE characters. The UNICODE values are international standard which allows for encoding for characters virtually for any character of any language. Example 1: Size of a single wide character This program demonstrates how to declare a single wide character using wchar_t to print its value and memory size. #include using namespace ...

Read More

Return from void functions in C++

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 10-Jun-2025 18K+ Views

The void functions are called void because they do not return anything. "A void function cannot return anything" this statement is not always true. From a void function, we cannot return any values, but we can return something other than values. Some of them are like below. A void function can return A void function cannot return any values. But we can use the return statement. It indicates that the function is terminated.ExampleThe following example demonstrates a void function with the return statement: #include using namespace std; void my_func() { cout

Read More

Exception handling and object destruction in C++

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 10-Jun-2025 989 Views

In this article, you will learn what is exception handling, object destruction, and Handing exception thrown in Object Destructor in C++. C++ Exception Handling An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another. C++ exception handling is built upon three keywords: try, catch, and throw. try: This block contains the code ...

Read More

Merge contents of two files into a third file using C

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 30-May-2025 1K+ Views

In C language, file handling is used for various file actions such as to write, read, merge, etc. Merging Contents of Two Files into a Third FileTo merge the contents of two files into a third file, you need to open the first two files (whose content will be merged into the third file) in read mode and the third file in write mode. After opening the files, read the contents of the first file and write them to the third file, and similarly with the second file and appending them to the third file. Example Scenario Imagine these are ...

Read More

Conversion constructor in C++?

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 30-May-2025 1K+ Views

In C++, a conversion constructor is a special type of constructor that takes only one argument. It enables automatic type conversion from the argument's type to the class type. When an object of the class to be created from a single value(int). then the compiler will call the conversion constructor to create the object from that value. This can be implicit conversion of a value into a class object. Creating Conversion Constructor Following is the syntax to the Conversion Constructor in C++: class ClassName { public: ClassName(Type arg); // Conversion constructor }; Here, ...

Read More

Line Splicing in C/C++

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 30-May-2025 772 Views

In C/C++, Line splicing is a small feature that lets you split one long line of code into two lines by using a special symbol that is the backslash (\).Line splicing is a preprocessor feature, not a function or method. It does not have any parameters. But it simply affects how lines of code are interpreted by the preprocessor before compilation.How to Use Line Splicing? If a line of code is too long, and you want to break it into multiple lines to make it easier to read. You can use a backslash at the end ...

Read More

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

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 27-May-2025 10K+ Views

The size of a pointer in C/C++ is not fixed. It depends upon different issues like Operating system, CPU architecture etc. Usually it depends upon the word size of underlying processor, for example for a 32 bit computer the pointer size can be 4 bytes and for a 64 bit computer the pointer size can be 8 bytes. So for a specific architecture pointer size will be fixed. It is common to all data types like int *, float * etc. Depending on the system architecture, pointer size may vary. The following table shows the pointer size based on the ...

Read More

Functors in C++

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 26-May-2025 472 Views

The functors are the function objects in C++. The functor allows an instance object of some class to be called as if it were an ordinary function. Let us consider a function that takes one argument. We can use this function as function object to do some task on a set of data. The Functors are widely used in STL algorithms like transform(), sort(), etc. Functor vs Regular Function: Need of Functor? Imagine we have a function that takes only one argument, like this: int increment(int x) { return x + 1; } Now, what ...

Read More

Catching base and derived classes exceptions in C++

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 07-May-2025 2K+ Views

To catch an exception for both base and derived classes, we need to put the catch block of the derived class before the base class. Otherwise, the catch block for the derived class will never be reached. This happens because C++ follows a top-down approach when checking catch blocks. So, by placing the derived class catch block first, we ensure that specific exceptions are handled correctly before falling back on the base class. Algorithm Following is the algorithm to catch Base and Derived classes Exceptions in C++: Begin Declare a class B. Declare another ...

Read More
Showing 11–20 of 65 articles
« Prev 1 2 3 4 5 7 Next »
Advertisements