Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

string
communitycreator

What is std::basic_string::cbegin in C/C++?

Naima Abrar

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code

cbegin() returns a constant iterator pointing to the first character of a string. This function does not have any parameters.

Syntax

my_string.cbegin()

Code

The following code returns the beginning character of a string. The begin_char variable stores the value the iterator points to.

#include <iostream>
int main()
{
std::string my_string1 = "Happy Learning at Educative!";
std::string begin_char;
begin_char = *my_string1.cbegin();
std::cout<<"First character: "<<begin_char<<"\n";
}

RELATED TAGS

string
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code
Keep Exploring