
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Program string class and its applications?
String is a sequence of characters. In C++ programming language, The strings can be defined in two ways −
C style strings: treats the string as a character array.
String Class in C++
The string class can be used in a C++ program from the library ‘string’. It stores the string as a character array in the memory but shows it as a string object to the user. In C++ there are many methods that support the C++ string class and help in the proper function of the object and increase the efficiency of the code.
Example
Some common string application are found where string are used −
#include <bits/stdc++.h> using namespace std; bool charcheck(string str) { int l = str.length(); for (int i = 0; i < l; i++) { if (str.at(i) < '0' || str.at(i) > '9') return false; } return true; } string replacedotWith20(string str) { string replaceby = "%20"; int n = 0; while ((n = str.find(" ", n)) != string::npos ) { str.replace(n, 1, replaceby); n += replaceby.length(); } return str; } int main() { string num = "3452i"; if (charcheck(num)) cout << "string contains only digit" << endl; else cout<<"string contains other characters too"<<endl; string url = "google com in"; cout << replacedotWith20(url) << endl; return 0; }
Output
String contains other characters too.
google%20com%20in
The above thing can be help while working with web.
- Related Articles
- C++ string class and its applications?
- Precentage And Its Applications
- Java instanceof and its applications
- MakeFile in C++ and its applications
- strchr() function in C++ and its applications
- What are the TCP/IP Ports and its applications?
- An overview of Anatomy, its types and their applications
- C++ program to create one rectangle class and calculate its area
- What is Machine Learning (ML) and its real-world applications?
- What is chromatography? State its two applications.
- What is Regex class and its class methods in C#?
- Class that contains a String instance variable and methods to set and get its value in Java
- Difference between String class and StringBuffer class in Java
- Why are carbon and its compounds used as fuels for most applications?
- Cloud Native Applications: Key Characteristics and Applications

Advertisements