A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_string_at.htm below:

C++ String at() Function

C++ String Library - at Description

It returns a reference to the character at position pos in the string.

Declaration

Following is the declaration for std::string::at.

char& at (size_t pos);
C++11
const char& at (size_t pos) const;
Parameters

pos − Value with the position of a character within the string.

Return Value

It returns a reference to the character at position pos in the string.

Exceptions

if an exception is thrown, there are no changes in the string.

Example

In below example for std::string::at.

#include <iostream>
#include <string>

int main () {
   std::string str ("Sairamkrishna Mammahe");
   for (unsigned i=0; i<str.length(); ++i) {
      std::cout << str.at(i);
   }
   return 0;
}
Sairamkrishna Mammahe 

string.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4