Connecting Tech Pros Worldwide Forums | Help | Site Map

Concatenate char to String

Poewood
Guest
 
Posts: n/a
#1: Nov 17 '05
Okay I know this is basic C++ but can someone tell me how to concatenate
char[] to string.
Ex:
char hexChar[]={'A','B','C','D','E','F'};
String *str ="A";

how can I do this:
str = hexChar[1] + hexChar[3]; or str = str + hexChar[3];

thanx,
Poe
Tomas Restrepo \(MVP\)
Guest
 
Posts: n/a
#2: Nov 17 '05

re: Concatenate char to String


> Okay I know this is basic C++ but can someone tell me how to concatenate[color=blue]
> char[] to string.
> Ex:
> char hexChar[]={'A','B','C','D','E','F'};
> String *str ="A";
>
> how can I do this:
> str = hexChar[1] + hexChar[3]; or str = str + hexChar[3];[/color]

If you're refering to System::String here, then the appropriate way would be
to use String::Concat(). You might want to make hexChar an array of
System::Char or wchar_t, instead, though...

--
Tomas Restrepo
tomasr@mvps.org


Poewood
Guest
 
Posts: n/a
#3: Nov 17 '05

re: Concatenate char to String


Thank you will do.

"Tomas Restrepo (MVP)" wrote:
[color=blue][color=green]
> > Okay I know this is basic C++ but can someone tell me how to concatenate
> > char[] to string.
> > Ex:
> > char hexChar[]={'A','B','C','D','E','F'};
> > String *str ="A";
> >
> > how can I do this:
> > str = hexChar[1] + hexChar[3]; or str = str + hexChar[3];[/color]
>
> If you're refering to System::String here, then the appropriate way would be
> to use String::Concat(). You might want to make hexChar an array of
> System::Char or wchar_t, instead, though...
>
> --
> Tomas Restrepo
> tomasr@mvps.org
>
>
>[/color]
Closed Thread