How to return an Array from a function in C++
Learn how to return old C style array from a function in C++.
Learn how to return old C style array from a function in C++.
This tutorial will discuss about a unique way to pass an array by reference to function in C++. Many times, we encounter a situation, where we need to pass a fixed size array to a function. For that we need to pass two data points in the function, Although, we can pass the array as …
This tutorial will discuss about a unique way to convert char array to an integer. In C++, the string.h header file provides a function stoi(). It accepts a character pointer as an argument, and interprets its contents as an integer value. It returns an int value. We can use this function to convert a char …
This tutorial will discuss about a unique way to check if char array is a number in C++. We can try to convert the char array to a double value. If we are successful in conversion, then it means we can convert a char array to double. We can use the stod() function to convert …
This tutorial will discuss about a unique way to check if two char arrays are equals. We can use the strcmp() function to compare two char arrays. It accepts two strings (char pointers) as arguments, and compares both the strings alphabetically. If both the strings are equal then it will return 0. So, to check …
In this article, we will discuss different ways to reverse an array in C++. Table Of Contents Problem Description Reverse an Array by creating another array Reverse an Array by swaping the values till half of the array Reverse an Array by using STL function Summary Problem Description Here we are given an array and …
In this article, we will learn how to initialize an array with range 1 to n in C++. Table Of Contents Initialize array with range using std::generate_n() Initialize array with range using std::iota Initialize array with range using For loop Summary Suppose if n is 10, then array contents whould be, We can think of …
How to initialize array with range 1 to n in C++? Read More »
In this article, we will discuss different ways to initialize an array of given size with same value in C++. Table Of Contents Problem Description Initialize an Array with same value using Initializer List Initialize an Array with same value using Designated Initializers Initialize an Array with same value using std::fill_n() function Initialize an Array …
How to initialize an Array with same value in C++? Read More »
In this article, we will discuss different ways to declare and initialize an array in C++. Table Of Contents How to declare an array in C++? How to Initialize an array in C++? Array Initialization by already declared array of specified size Array Initialization by initializing elements User defined array declaration and array initialization Summary …
In this article, we will discuss different ways to check if a C++ array contains duplicates or not. Table Of Contents Problem Description Check if array contains duplicates using Iterative approach with two loop Check if array contains duplicates using sort() function Check if array contains duplicates using map Check if array contains duplicates using …