Home » C++ String at() function

C++ String at() function

by Online Tutorials Library

C++ String at()

This function is used for accessing individual characters.

Syntax

Consider a string str. To find the position of a particular character, its syntax would be

Parameters

pos : It defines the position of the character within the string.

Return value

It returns the character specified at that position.

Example 1

Output:

String contains Welcome to TutorAspire tutorial  

Example shows that we can access the characters by using either the member function at() or the subscript operator[ ].

Next TopicC++ Strings

You may also like