Answers for "c++ get last character of string"

C++
1

c++ get last character of string

// Example
YourStr.substr(YourStr.length() - 1)

// Syntax
std::string YourStr = "abcdef";
std::cout << YourStr.substr(YourStr.length() - 1) << "\n"; // OUTPUT: f
Posted by: Guest on May-05-2021
1

find last occurrence of character in string c++

auto find_char = 'a'
size_t last_occurence_index = str.find_last_of(find_char);
Posted by: Guest on September-15-2020
0

how to find last character of string in c++

String[strlen(String) - 1];
Posted by: Guest on December-07-2020

Code answers related to "c++ get last character of string"

Browse Popular Code Answers by Language