Avronil Chakraborty

Replace character in string at a particular index in C++

In this article, we will discuss different ways to replace a character in string at a particular index in C++. Table Of Contents Introduction Case 1: The index of the character to be replaced and the new character are given as input. Using std::string::replace() Using the [] operator Case 2: The character to be replaced

Replace character in string at a particular index in C++ Read More »

Split String into Substrings of equal length in C++

In this artcile, we will discuss different ways to split a string into multiple substrings of equal lemnth in C++. Table Of Contents Introduction Method 1: Using substr() Method 2: Using iterators Summary Introduction There can be two variations for the given problem:1. The number of substrings is given and we need to calculate the

Split String into Substrings of equal length in C++ Read More »

Convert an Integer to a Hexadecimal String in C++

A hexadecimal string contains only hexadecimal digits and an optional “0x” prefix. The article here discusses various ways to convert an integer to a hexadecimal string (with the “0x” prefix). The converted string is in lowercase and can be converted to uppercase using toupper() function in C++. Table Of Contents Method 1: Using a For

Convert an Integer to a Hexadecimal String in C++ Read More »

Convert a Hexadecimal String to an Integer in C++

A hexadecimal string contains only hexadecimal digits and an optional “0x” prefix. The article here discusses various ways to convert a hexadecimal string (with the “0x” prefix) to its corresponding integer value (with a note included after each method containing the changes to be made in the code in case of the hexadecimal string not

Convert a Hexadecimal String to an Integer in C++ Read More »

Convert a String to a Vector of Bytes in C++

The article here discusses various ways to convert an input string to a vector of bytes in C++. Table Of Contents Method 1: Using a For Loop Method 2: Using std::vector Constructor Method 3: Using std::transform method Method 4: Using std::copy() method Summary Method 1: Using a For Loop This program creates a string called

Convert a String to a Vector of Bytes in C++ Read More »

Scroll to Top