Re: split a /path/filename into components
- From: Rikishi 42 <fsck_spam@xxxxxxxxxx>
- Date: Fri, 25 Aug 2006 18:57:20 +0200
Josef Moellers wrote:
But wasn't there a strtok() function in C, that would split a string,
based on a given char ? Us '/' as that char, and you should be fine.
The strtok function has too many problems to be really usefull.
From the manual page:
Never use these functions. If you do, note that:
These functions modify their first argument.
These functions cannot be used on constant strings.
The identity of the delimiting character is lost.
The strtok() function uses a static buffer while parsing,
so it's not thread safe. Use strtok_r() if this matters to you.
Aha! Now I remmeber. Yes, you had to work on a copy of the string. No wonder
I didn't use it since 1993. :-)
Well, maybe the OP can take a look at it, or just sweep the string for '/'
himself, creating new string as he goes.
Thanks for the info.
--
Research is what I'm doing, when I don't know what I'm doing.
(von Braun)
.
- References:
- Re: split a /path/filename into components
- From: Rikishi 42
- Re: split a /path/filename into components
- From: Josef Moellers
- Re: split a /path/filename into components
- Prev by Date: Re: split a /path/filename into components
- Next by Date: Re: split a /path/filename into components
- Previous by thread: Re: split a /path/filename into components
- Next by thread: Re: split a /path/filename into components
- Index(es):
Relevant Pages
|