From: Leigh Johnston on 27 Jan 2010 20:26 "Stephan T. Lavavej [MSFT]" <stl(a)microsoft.com> wrote in message news:OHO9KO7nKHA.5524(a)TK2MSFTNGP05.phx.gbl... > strtok() is terrible. Instead, use regex_token_iterator to perform field > splitting: Although horrid and old fashioned I suspect using strtok is ten times faster than using regex to do basic tokenisation! Perhaps boost.tokenizer would be a better recommendation although I have not used it myself. I have written my own tokenizer to do such things (they are not exactly hard to write). /Leigh
From: Igor Tandetnik on 27 Jan 2010 20:37 Leigh Johnston wrote: > "Stephan T. Lavavej [MSFT]" <stl(a)microsoft.com> wrote in message > news:OHO9KO7nKHA.5524(a)TK2MSFTNGP05.phx.gbl... >> strtok() is terrible. Instead, use regex_token_iterator to perform field >> splitting: > > Although horrid and old fashioned I suspect using strtok is ten times faster > than using regex to do basic tokenisation! Perhaps boost.tokenizer would be > a better recommendation although I have not used it myself. I have written > my own tokenizer to do such things (they are not exactly hard to write). In any case, the OP has indicated that he is, unenviably, limited to C, so neither suggestion is probably going to be of much help. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: DS on 27 Jan 2010 20:40 Well I had this statement and was wondering why it hanged :) while ( isgraph( sUserCmd[i] ) ); i++; Dan (too many semicolons) (PS: Thought I'd sent it to the group.) ----- Original Message ----- From: "Igor Tandetnik" <itandetnik(a)mvps.org> Newsgroups: microsoft.public.vc.language Sent: Wednesday, January 27, 2010 6:58 PM Subject: Re: Declaring a dynamic pointer to an array of char pointers DS <dsutNOSPAMter(a)tc3NOSPAMnet.com> wrote: > "Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message > news:uyHLvg6nKHA.3948(a)TK2MSFTNGP06.phx.gbl... >> But I respectfully submit you'd be much better off with something >> like vector<string> . > > (I hoped this was a 'C' group.) >There is no group dedicated to C in microsoft.public.* hierarchy. I suppose if such a group existed, it would be pretty lonely >there. People here generally don't mind > pure C questions though, but you should note in your posts that you are thus limited: C++ is assumed by default. "Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message news:u2T2ty6nKHA.1928(a)TK2MSFTNGP05.phx.gbl... DS <dsutNOSPAMter(a)tc3NOSPAMnet.com> wrote: > "Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message > news:uyHLvg6nKHA.3948(a)TK2MSFTNGP06.phx.gbl... >> But I respectfully submit you'd be much better off with something >> like vector<string> . > > (I hoped this was a 'C' group.) There is no group dedicated to C in microsoft.public.* hierarchy. I suppose if such a group existed, it would be pretty lonely there. People here generally don't mind pure C questions though, but you should note in your posts that you are thus limited: C++ is assumed by default. >> This sounds suspciously like strtok() > > Sure, but it(strtok()) may not be available in my environment. If you say so, though I'd like to mention that strtok is part of the standard C library. In any case, there are plenty of implementations of strtok published under various licenses: perhaps you can borrow one. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Giovanni Dicanio on 28 Jan 2010 11:24 "DS" <dsutNOSPAMter(a)tc3NOSPAMnet.com> ha scritto nel messaggio news:uQhIpY6nKHA.5520(a)TK2MSFTNGP05.phx.gbl... > I would like to declare a pointer to an array of char pointers, that > I can allocate at some time during a run. > I'll expect a variable length string of tokens seperated by white space > chars. > I would like to search for each token head and store it's address in a > sequential > array of pointers, Then insert a NULL at each tokens end. > ie: string = "Cmd Arg1 Arg2 Arg3..." > > Now I tried: > char ** PtrArray; > But the program hanged. char** would be just fine in pure C. > I have turned my "C Reference Manual inside and out. > I have read several web documents, pointer tutorials... > Please help, Considering that you are asking for a pure C solution, you may find useful a simple C tokenzier I wrote and attached here. It seems to work in some tests, but it needs more verification. Note that if you could use C++, vector<CString> would be better choice than raw C-like array of pointers. (To my limited knowledge, there are few cases in which you must use pure C instead of C++, like e.g. developing device drivers in kernel mode; if you aren't in this elite, C++ could make your life easier.) HTH, Giovanni
From: Bo Persson on 28 Jan 2010 11:49 Leigh Johnston wrote: > "Stephan T. Lavavej [MSFT]" <stl(a)microsoft.com> wrote in message > news:OHO9KO7nKHA.5524(a)TK2MSFTNGP05.phx.gbl... >> strtok() is terrible. Instead, use regex_token_iterator to >> perform field splitting: > > Although horrid and old fashioned I suspect using strtok is ten > times faster than using regex to do basic tokenisation! Perhaps > boost.tokenizer would be a better recommendation although I have > not used it myself. I have written my own tokenizer to do such > things (they are not exactly hard to write). > /Leigh Yes, so you can parse the user input in 10 ns instead of 100? :-) Bo Persson
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: WaitForSingleObject Next: problem with scope and functions |