BEST SITE FOR WEB DEVELOPERS

C++ Tutorial

C++ HOME C++ Intro C++ Get Started C++ Syntax C++ Output C++ Comments C++ Variables C++ User Input C++ Data Types C++ Operators C++ Strings C++ Math C++ Booleans C++ Conditions C++ Switch C++ While Loop C++ For Loop C++ Break/Continue C++ Arrays C++ Structures C++ Enums C++ References C++ Pointers

C++ Functions

C++ Functions C++ Function Parameters C++ Function Overloading C++ Scope C++ Recursion

C++ Classes

C++ OOP C++ Classes/Objects C++ Class Methods C++ Constructors C++ Access Specifiers C++ Encapsulation C++ Inheritance C++ Polymorphism C++ Files C++ Exceptions C++ Date

C++ How To

Add Two Numbers Random Numbers

C++ Reference

C++ Reference C++ Keywords C++ <iostream> C++ <fstream> C++ <cmath> C++ <string> C++ <cstring> C++ <ctime>

C++ Examples

C++ Examples C++ Compiler C++ Exercises C++ Quiz C++ Certificate

C++ Language. W3Schools in English. Lessons for beginners

Ua Es De Fr

C++ string Library


C++ string Functions

The <string> library has many functions that allow you to perform tasks on strings.

A list of popular string functions can be found in the table below.

Function Description
at() Returns an indexed character from a string
length() Returns the length of a string
size() Alias of length(). Returns the length of a string
max_size() Returns the maximum length of a string
empty() Check whether a string is empty or not
append() Append a string (or a part of a string) to another string
substr() Returns a part of a string from a start index (position) and length
find() Returns the index (position) of the first occurrence of a string or character
rfind() Returns the index (position) of the last occurrence of a string or character
replace() Replaces a part of a string with another string
insert() Inserts a string at a specified index (position)
erase() Removes characters from a string
compare() Compares two strings


Comments