Sum of array using pointer arithmetic
Given an array, write a program to find the sum of array using pointers arithmetic. In this program we make use of * operator . The * (asterisk) operator denotes the value of variable. The * operator at the time of declaration denotes that this is a pointer, otherwise it denotes the value of the memory location pointed by the pointer . sum() function is used to find the sum of the array through pointers....
read more
How to Return a Pointer from a Function in C++?
In C++, we can return a pointer from a function which is useful when we want to return large data structures that cannot be returned by value. However, it must be done carefully to avoid memory leaks, dangling pointers, and other issues related to dynamic memory management. In this article, we will learn how to return a pointer from a function in C++....
read more
Pass Array to Functions in C
In C, the whole array cannot be passed as an argument to a function. However, you can pass a pointer to an array without an index by specifying the array’s name....
read more
Why is Conversion From String Constant to ‘char*’ Valid in C but Invalid in C++?
In both C and C++, strings are sequences of characters enclosed in double-quotes. In this article, we will learn why is the conversion from string constant to ‘char*’ valid in C but invalid in C++....
read more
How to use const with Pointers in C++?
In C++, the const keyword is used as a type qualifier for defining read-only (immutable) objects that cannot be modified anywhere in their lifetime. It can be used in several ways with pointers, each serving a different purpose. In this article, we will learn how to use const qualifier with pointers in C++....
read more
When Do We Pass Arguments by Reference or Pointer in C++?
In C++, we can pass arguments to a function as a value, reference (or pointer). Each method has its unique benefits and uses. In this article, we will discuss the application or cases where we should pass the arguments by reference or a pointer. But first, let’s quickly revisit the definitions of pointers and references....
read more
Passing Pointers to Functions In C++
Prerequisites:...
read more
‘this’ pointer in C++
To understand ‘this’ pointer, it is important to know how objects look at functions and data members of a class....
read more
How to Create a Dynamic 2D Array Inside a Class in C++?
A dynamic array is an array that can grow, resize itself, contains a dynamic table, which is mutable in nature, or an array list is randomly accessible, the variable-size list data structure that allows elements to be added or removed....
read more
Clockwise/Spiral Rule in C/C++ with Examples
The Spiral/Clockwise Method is a magic tool for C/C++ programmers to define the meaning of syntax declaration in the head within seconds. This method was created by David Anderson and here is a short brief about how to apply this method....
read more
Creating array of pointers in C++
An array of pointers is an array of pointer variables. It is also known as pointer arrays. We will discuss how to create a 1D and 2D array of pointers dynamically. The word dynamic signifies that the memory is allocated during the runtime, and it allocates memory in Heap Section. In a Stack, memory is limited but is depending upon which language/OS is used, the average size is 1MB....
read more
How to declare a 2D array dynamically in C++ using new operator
Prerequisite: Array BasicsIn C/C++, multidimensional arrays in simple words as an array of arrays. Data in multidimensional arrays are stored in tabular form (in row major order). Below is the general form of declaring N-dimensional arrays:...
read more