"pentiumPunk" <Br***@triad.rr.com> wrote in message
news:Tl*********************@twister.southeast.rr. com...
Hi, I created an array of characters and want to convert that array to a
string.
I want to do something like this :
char array1 [25]; //with letters already in it
string string1;
string1 = array1;
That wont work will it? what would be the proper syntax? thanks in ahead!
If the string in array1 is null-terminated:
string1.assign( array1 );
or, better, direct initialization:
string string1( array1 );
If array1 is not null-terminated:
string1.assign( array1, array1+25 );
or: string1.assign( array1, 25 );
And there is a pair of matching constructors that
accept the same parameters:
string string1( array1, array1+25 );
or: string string1( array1, 25 );
Too much choice indeed...
hth
--
Ivan Vecerina, Dr. med. <>
http://www.post1.com/~ivec
Brainbench MVP for C++ <>
http://www.brainbench.com