Returns a reference to the character at the specified location pos. The function automatically checks whether pos is the valid position of a character in the string (i.e., whether pos is less than the string length), throwing an out_of_range exception if it is not.
reference at (size_type pos); const_reference at (size_type pos) const; Parameters : pos - position of the character to return Return value : Reference to the requested character Exceptions : Throws std::out_of_range if pos >= size().
string size = 3 basic_string::at: __n (which is 4) >= this->size() (which is 3)
This article is contributed by Rohit Thapliyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Introduction of Hyperledger
- Comparison Networks
- HijrahDate getEra() method in Java with Example
- HijrahDate getChronology() method in Java with Example
- HijrahDate equals() method in Java with Example
- HijrahDate atTime() method in Java with Example
- HijrahChronology range() method in Java with Example
- HijrahChronology zonedDateTime(TemporalAccessor) method in Java with Example
- Vector of Vectors in C++ STL with Examples
- Array of Vectors in C++ STL
- Compression of GIF images
- Features of Blockchain
- Eggs dropping puzzle | Set 2
- Difference between Information and Data
- Time of Flight (ToF) Sensors