MistyD
MistyD

Reputation: 17253

Returning certain characters from string - BOOST STRING

Does boost string have any methods that might assist me in returning a certain no of characters from a string if their position is specified. For instance something like

Left(std::string("Hello"),2)

might return "He". I checked the library page at here but could not find anyhing.

Upvotes: 0

Views: 52

Answers (1)

Andy Prowl
Andy Prowl

Reputation: 126552

Just use std::string's member function substr():

std::string("Hello").substr(0, 2);

Here is a live example.

Upvotes: 3

Related Questions