Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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++ If...Else 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++ Data Structures

C++ Data Structures & STL C++ Vectors C++ List C++ Stacks C++ Queues C++ Deque C++ Sets C++ Maps C++ Iterators C++ Algorithms

C++ How To

C++ Add Two Numbers C++ Random Numbers

C++ Reference

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

C++ Examples

C++ Examples C++ Real-Life Examples C++ Compiler C++ Exercises C++ Quiz C++ Syllabus C++ Study Plan C++ Certificate


C++ cstring Library


C++ cstring Functions

The <cstring> library has many functions that allow you to perform tasks on arrays and C-style strings.

Note that C-style strings are different than regular strings. A C-style string is an array of characters, created with the char type. To learn more about C-style strings, read our C Strings Tutorial.

A list of all cstring functions can be found in the table below.

Function Description
memchr() Returns a pointer to the first occurrence of a value in a block of memory
memcmp() Compares two blocks of memory to determine which one represents a larger numeric value
memcpy() Copies data from one block of memory to another
memmove() Copies data from one block of memory to another accounting for the possibility that the blocks of memory overlap
memset() Sets all of the bytes in a block of memory to the same value
strcat() Appends one C-style string to the end of another
strchr() Returns a pointer to the first occurrence of a character in a C-style string
strcmp() Compares the ASCII values of characters in two C-style strings to determine which string has a higher value
strcoll() Compares the locale-based values of characters in two C-style strings to determine which string has a higher value
strcpy() Copies the characters of a C-style string into the memory of another string
strcspn() Returns the length of a C-style string up to the first occurrence of one of the specified characters
strerror() Returns a C-style string describing the meaning of an error code
strlen() Return the length of a C-style string
strncat() Appends a number of characters from a C-style string to the end of another string
strncmp() Compares the ASCII values of a specified number of characters in two C-style strings to determine which string has a higher value
strncpy() Copies a number of characters from one C-style string into the memory of another string
strpbrk() Returns a pointer to the first position in a C-style string which contains one of the specified characters
strrchr() Returns a pointer to the last occurrence of a character in a C-style string
strspn() Returns the length of a C-style string up to the first character which is not one of the specified characters
strstr() Returns a pointer to the first occurrence of a C-style string in another string
strtok() Splits a string into pieces using delimiters
strxfrm() Convert characters in a C-style string from ASCII encoding to the encoding of the current locale

Learn more about c-style strings in our C-Style Strings Tutorial.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.