2 registered members (AndrewAMD, TipmyPip),
844
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Compare part of a char*.
[Re: Ercoles]
#370757
05/15/11 14:06
05/15/11 14:06
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
You can use Lite Foundations string class for this:
LFStringRef lfString = LFStringWithCString(yourCString);
if(LFStringHasSuffix(lfString, LFSTR(".ssv"))
{
// Here comes your code...
}
(Beside that, you can also compare any other range with Lite Foundations string class)
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Compare part of a char*.
[Re: Ercoles]
#370763
05/15/11 14:32
05/15/11 14:32
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Just download Lite Foundation and put it into your projects folder. You just need to include "LiteFoundation.h" and call LFRuntimeInit() at startup. Download link: http://cl.ly/6ghGThe example files show you how to include it correctly (Arrays.c, Strings.c, Sets.c or Scanner.c)
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Compare part of a char*.
[Re: Slin]
#370768
05/15/11 14:41
05/15/11 14:41
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Not really, because the searched suffix can also be in the middle of the string and the Gstudio function would happily return true ![wink wink](/ubb7/images/graemlins/default_dark/wink.gif)
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Compare part of a char*.
[Re: WretchedSid]
#370770
05/15/11 14:49
05/15/11 14:49
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
It is still easier to use str_stri...
if(str_stri(yourstring, ".ssv"))
{
//do something
}
Nothing else needed.
|
|
|
Re: Compare part of a char*.
[Re: Slin]
#370772
05/15/11 14:57
05/15/11 14:57
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Sure its easier but again, its more likely to break plus Lite Foundations string class is a bit faster because it starts the search at the very end and not at the very beginning like Gstudios function (thats not really noticeable but worth noting imo).
Another thing is: When he gets used to LF now, he can later adopt it more easily and LFs string class together with the other classes is way more powerful than Gstudios implementations.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|