Tuesday, April 24, 2012

substr, end of the string


#include <string>
#include <iostream>
using namespace std;

int main(){
  string s("abc");
  std::cout<<s.substr(3)<<std::endl;
   
}

with 3 it is fine, and a null string is returned
with 4, std::out_of_range is thrown

No comments:

Post a Comment