From: DS on 28 Jan 2010 17:33 Grazi Giovanni, The file is very helpful. DS "Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote in message news:ePwXSZDoKHA.5552(a)TK2MSFTNGP05.phx.gbl... > "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: Giovanni Dicanio on 28 Jan 2010 17:38 "DS" <dsutNOSPAMter(a)tc3NOSPAMnet.com> ha scritto nel messaggio news:O4UK4nGoKHA.3948(a)TK2MSFTNGP06.phx.gbl... > Grazi Giovanni, > The file is very helpful. DS: You are welcome. Giovanni
From: Tim Roberts on 28 Jan 2010 23:45
"Leigh Johnston" <leigh(a)i42.co.uk> wrote: >"Stephan T. Lavavej [MSFT]" <stl(a)microsoft.com> wrote: in message > >> 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). Yes. Note, however, that the ATL CString implementation contains CString::Tokenize, which serves the same purpose safely. Not as quickly as strtok, but faster than a regex. -- Tim Roberts, timr(a)probo.com Providenza & Boekelheide, Inc. |