Re: strange behaviour with `substr()` function
- From: Nicolas Jäger <jagernicolas legtux org>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: strange behaviour with `substr()` function
- Date: Wed, 26 Aug 2015 11:36:12 -0400
Hi Marcin,
Ok... I thought that the result of `substr(a,b)` meant to remove all
chars before `a` and after `b`... like when doing `erase( 0, a )` then
`erase(b)`.
thx.
regards,
nicolas
Le Wed, 26 Aug 2015 16:36:18 +0200,
Marcin Kolny <marcin kolny gmail com> a écrit :
I see nothing wrong with that. Then if I use the `substr()` function,
I
don't understand why I got, for the case (0,4): gtkm and for the
case (1.5) gtkmm.
substr() method internally creates a new Glib::ustring object using
constructor [1] (actually, it's the same behavior as substr() from
std::string [2]). So, substr(0, 4) means: get 4 characters from
string, but start from index 0. Four first letters of "gtkmm" string
are 'g', 't', 'k' and 'm'.
[1]
https://developer.gnome.org/glibmm/stable/classGlib_1_1ustring.html#a37655e890b5cb3a2f0fc862b85ba29cc
[2] http://www.cplusplus.com/reference/string/string/substr/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]