"Newsnet Customer" <> wrote in message
news:...
> > > What's the most efficient (mem) way to copy string 'a' to string 'b'?
> Now
> > i
> > > do:
> > >
> > > char a[1000];
> > > char* b; // length not known...could be 1000
> > > strcpy(a, b);
> > >
> > > Is it really necessary that 'a' always gets allocated the max size of
> 'b',
> > > or can this be done more efficiently?
> > >
> > > Thanks in advance,
> > > Mark
> > >
> >
> > The most efficient way to copy a string is to use the std::string class.
> >
> > #include <string>
> >
> > std::string a = whatever;
> > std::string b = a; // copies string a to string b
> >
> > Don't mess around with char arrays, learn some proper C++ and use the
C++
> > string class.
>
>
> what is the std namespace used for? used for all C++ header files?
>
> asasas
>
The std namespace is for the C++ standard library, which means things like
std::string, std::cout, std::vector, std::map etc. Any standard header file
without a .h is the C++ standard library.
john
|