Answers for "string.back() in c++"

C++
1

back() in c++

// my linkedin : https://www.linkedin.com/in/vaalarivan-prasanna-3a07bb203/
vector<int> vec = {1, 2, 5, 6};
int ele = vec.back();  //ele = 6
//back() method does delete the last element from the vector, it just returnsn
//the last element.
Posted by: Guest on April-19-2021
0

c++ back()

// string::back
#include <iostream>
#include <string>

int main ()
{
  std::string str ("hello world.");
  str.back() = '!';
  std::cout << str << 'n';
  return 0;
}
Posted by: Guest on June-10-2021

Browse Popular Code Answers by Language