
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

17K+ Views
In this article, we will learn all the different approaches to remove the whitespaces from a standard string in C/C++. First of all, let's understand our problem statement. The input of this problem is a non-empty string containing multiple characters and whitespaces between those characters. Our task is to print the string by ignoring all the whitespaces into the output console. For example: // Input String "This is a string" // Output String "Thisisastring" Remove Whitespaces from a String in C++ Here is the list of approaches to remove all the whitespaces from a string using ... Read More

569 Views
Sometimes, in C++ when you try to print a string that containing special characters like escape sequences (), backslashes (\), or quotes(""), the output may not be as expected. To avoid this, C++ provides a feature called raw string literal. In this article, we will discuss what is raw string literal and how to use it in C++. What is Raw String Literal? A raw string literal in C++ is a type of string that preserves the formatting of the string content without changing any escape sequences such as "", "\t", or "". This is useful when you want ... Read More

15K+ Views
Here in this program we will see how to iterate through each characters of a string in C++. To loop on each character, we can use loops starting from 0 to (string length – 1). For accessing the character we can either use subscript operator "[ ]" or at() function of string object. Input: A string "Hello World" Output: "Hello World" Algorithm Step 1: Get the string Step 2: Use R before string to make it raw string Step 3: End Example Code #include using namespace std; int main() { string my_str = "Hello World"; for(int i = 0; i

8K+ Views
In this article, we will discuss all the approaches to parse a string delimited by comma using a C/C++ program. First of all, let's understand the problem statement. The input of this problem is a string containing multiple words that are seperated by commas. Our task is to print each word space seperated to the output console. For example: // Input String "Hello, World, From, 2025" // Output "Hello" "World" "From" "2025" Parse Comma Delimited String Here is the list of approaches to parse comma delimited string to words using c++ program, which we ... Read More

1K+ Views
Sting Concatenatination is the process of creating a single string from multiple strings by combining them all together. In this article, we will discuss all approaches to concatenate multiple strings using C/C++ program. First of all, let's understand the problem statement. A set of C++ strings are given as input. We need to output a single string which is concatenate of the strings provided. For example: // Input Strings "Value " "is " "Big" // Output String "Value is Big" Concatenate Multiple Strings to Single Line Here is the list of approaches ... Read More

2K+ Views
Concatenate a string and an integer means, convert both the string and integer to a single string. In this article we will discuss all the approches to concatenate a std:string and an integer type using C/C++ program. First of all, let's understand the problem statement. We are given a standard c++ string and an integer. We have to output a single string by combining the given string and integer. For example: // Input String and Integer "Value = " 25 // Output String "Value = 25" Concatenate String and Int in C++ Here is the list ... Read More

693 Views
Reversing a string means, moving first character to last, second character to second last and so on. In this article we will discuss how to reverse a string in place using C/C++ program. In the "in place" string reversing, we are not allowed take extra memory to store the string while running program. First of all, let's understand our problem statement:We are given a character string as input and we need to find and output the reverse string of the given string. For example: // Input : a character string "This is a string" //Output : Reverse of ... Read More

906 Views
Alpha-numeric string are the strings that containing both alphabets and numbers mixed together. These are generally used in security system for generating passwords or hash keys. In this article, we will learn all the approaches for developing a C++ program to generate random alpha numeric stiring. First of all, let's understand the problem statement, We have to input a positive integer for the length of string. The program should output a string of the size containing random characters and numbers. For example, // Input Number : Length of alpha-numeric string 5 // Output String : Alpha-numeric string fd23j ... Read More

7K+ Views
In this article, we will discuss how to extract all the integers from a string using C++ program. We will explore all the possible approaches to do so. First of all, let's understand the problem statement. We have a string that contains a mix of digits and non-digits. We need to extract all the integers from the string and store them in a vector. The integers can be positive or negative. For example, // Input String string str = "ab24wj-123fow" // Output Vector vector vec = {24, -123} Approaches to Extract Integers from String ... Read More

855 Views
In this article, we will see how to convert a string to a number and a number to string using modern C++ techniques. Understanding Strings and Numbers In C++, strings and numbers are two different data types. A string is a sequence of characters enclosed in double quotes, and a number can be any numerical value such as integer, float, double, etc. Strings are used to represent text data and numbers are used for mathematical calculations. Let's see an example of defining a string and number. // Define a string string str = "Hello World"; // Define ... Read More