String Position Guidance

Jan 8, 2014 at 6:03am
I have this following code from the c++ reference page. In this code, I have str.assign(base,10,9) I have three parameters with second parameter(10) being the position. My question is that when it says position 10, where would it be on my string. Do I count it from 0 or 1, when getting position 10?

1
2
3
4
5
6
7
8
9
10
11
12
  
  std::string str;
  std::string base="The quick brown fox jumps over a lazy dog.";

  // used in the same order as described above:

  str.assign(base);
  std::cout << str << '\n';

  str.assign(base,10,9);
  std::cout << str << '\n';         // "brown fox"
Jan 8, 2014 at 6:17am
The first character is position 0.

So position 10 would be the 11th character.
Jan 9, 2014 at 2:21am
got it thank you! :)
Topic archived. No new replies allowed.