Home

On Oct 3, 12:52 am, "Alf P. Steinbach" <al...@start.no> wrote:
> * Chris ( Val ):
>
>
>
>
>
> > On Oct 2, 4:33 pm, "Alf P. Steinbach" <al...@start.no> wrote:
> >> * Andrew Wingorodov:
>
> >>> i have std::vector<string> arg; for dynamic program configuration.
> >>> i need get const char* argv[]; for execv(3).
> >>> how i can make its simple?
> >>> there may be ready solutions?
> >> std::vector<string> arg;
> >> ...
>
> >> std::vector<char const*> v( arg.size() );
> >> for( size_t i = 0; i < v.size(); ++i ) { v[i] = arg[i].c_str(); }
> >> blahblah( &v[0] );
>
> > Whay go through all that when he already has what he wants
> > in his original vector?
>
> > const char* tmp = arg.at( n ).c_str();
>
> Andrew wants an array of pointers to C-strings, for use as execv
> argument (later down the thread I checked execv's signature and found
> that there's also a const issue, and that the array should be
> null-terminated, but those are just technicalities).

I see.

> What you have is one pointer to a C-string.

Yes.

I thought that would be sufficient for the OP's needs,
and didn't see the necessity of an additional vector :-)

--
Chris Val

previous
next

Re: question for returning an array
Class for custom Tkinter widget--difficulty
execfile and function call
Re: Visual C++ Express Edition or lcc-win32?
Re: uninstall python2.5 on debian
Wróżenie
palmtop
poker
Veľkoobchod bižutéria
wzory tatuaży