# char-array

## Convert Char Array to Double or Number in C++

This tutorial will discuss about a unique way to convert char array to double or number. In C++, the string.h header file provides a function stod(). It accepts a character pointer as an argument, and interprets its contents as a floating point number. It returns a double value. We can use this function to convert […]

## Convert Char Array to an integer in C++

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

## Check if Char Array is a Number in C++

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

## How to initialize a Char Array in C++?

This tutorial will discuss about a unique way to initialize a char array in C++. We can initialze a char array with a string while defining the array. Like this, But we need to make sure that the array is big enough to hold all the characters of string. Otherwise you will get compile error.

## Check if two char arrays are equals in C++

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

## Check if Char Array Starts with a string in C++

This tutorial will discuss about a unique way to check if char array starts with a string. To check if a char array starts with another string or char array, we can follow the following steps, Let’s see the complete example, Output : Summary Today we learned about several ways to check if char array

## Check if Char Array contains a char in C++

This tutorial will discuss about a unique way to check if char array contains a char in C++. To check if a char contains a specific character, iterate over all the characters of char array and check if any character matches with the given character. As soon as a match is found, break the loop

## Check if a Char Array is equal to a string in C++

This tutorial will discuss about unique ways to check if a char array is equal to a string. Table Of Contents Technique 1: Using strcmp() Technique 2: Using string::compare() function Summary Technique 1: Using strcmp() The strcmp() function accepts two strings (char pointers) as arguments, and returns 0 if both the strings are equal. We

## Get the length of char array in C++

This tutorial will discuss about a unique way to get the length of char array in C++. Get maximum number of elements an array can hold We can get the length of a char array, just like an another array i.e. fetch the actual size of array using sizeof(arr), and divide it with the size

## Check if a Char Array is Null Terminated in C++

This tutorial will discuss about unique ways to check if a char array is null terminated. Table Of Contents Technique 1: Using STL Algorithm any_of() Technique 2: Check if char array is null terminated Summary Technique 1: Using STL Algorithm any_of() To check if a char array has any ‘\0’ character or not, we can

Scroll to Top