C++ String Functions

Beginner
6 min read
Updated: Nov 2026
15 function guides
Function index

About This Index

This page is the C++ String Functions index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.

Learn what a string is on /cpp/string. Use this page when you need a specific API such as find(), strlen(), or strcmp().

Beginner path.

Start with find() for std::string, then strlen(), strcmp(), and strcpy() for C-string basics.

How to Call a String Function

Call std::string members with a dot; call <cstring> helpers by name:

C++
#include <string>
#include <cstring>

std::string text = "Hello, C++!";
std::size_t pos = text.find("C++");   // member

const char* c = "Hello";
std::size_t n = std::strlen(c);       // cstring
int cmp = std::strcmp(c, "Hello");    // 0 when equal

C++ String Functions Table

All function guides in this C++ tutorial series (15 tutorials).

Copy & concatenate

4 functions

Copy and append C-strings into char buffers.

FunctionDescriptionTutorial
strcpy()Copy a C-string into a destination buffer.Try it
strcat()Append one C-string to another.Try it
strncpy()Copy at most n characters.Try it
strncat()Append at most n characters.Try it

Compare & collate

3 functions

Lexicographic comparison of C-strings.

FunctionDescriptionTutorial
strcmp()Compare two C-strings.Try it
strncmp()Compare at most n characters.Try it
strcoll()Locale-aware string comparison.Try it

Scan & span

3 functions

Search character sets and measure initial segments.

FunctionDescriptionTutorial
strpbrk()Find first char that matches any in a set.Try it
strspn()Count leading chars in an accept set.Try it
strcspn()Count leading chars not in a reject set.Try it

Diagnostics

1 function

Turn error codes into readable messages.

FunctionDescriptionTutorial
strerror()Message for an errno error code.Try it

Frequently Asked Questions

C++ offers std::string members like find() and C-style helpers from <cstring> such as strlen(), strcpy(), and strcmp(). Both appear in real programs and interviews.
The Strings page teaches what a string is—std::string, +, length(), and when to use cstring. This Functions index lists every function tutorial so you can open find(), strlen(), strcmp(), and the rest.
Use #include <string> for std::string and find(). Use #include <cstring> for strlen, strcpy, strcmp, and related C helpers.
strcpy() copies the whole source with no length limit. strncpy() copies at most n characters and may leave the result unterminated if the source is longer than n. Always size buffers carefully.
If you are new, read C++ Strings first. Then open find(), strlen(), strcmp(), and strcpy() from the table below.

Start with find()

Open the std::string search guide—syntax, examples, and FAQs.

find() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful