Re: char to string ????

From: Phil... (rynes_at_ieee.org)
Date: 10/28/03


Date: Tue, 28 Oct 2003 17:17:54 GMT

my book says left to right also

"Glen Herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message
news:I6onb.47477$HS4.225638@attbi_s01...
>
> "Tarken" <tarken@lycos.co.uk> wrote in message
> news:e9358f13.0310271213.11aa5c46@posting.google.com...
> > HGA03630@nifty.ne.jp (hiwa) wrote in message
> news:<6869384d.0310250203.395b69ce@posting.google.com>...
> > > "Jova" <Name@dotcom.com> wrote in message
> news:<FRemb.14426$gA1.4132498@news4.srv.hcvlny.cv.net>...
> > > > Is there a method or way for me to take a couple of char's and make
a
> sting
> > > > out of them .
> > > >
> > > > Example of what I want to do.
> > > >
> > > > String | char
> > > > b = b
> > > > ba = a
> > > > bad = d
> > > couple of char ... char[] couple = {'m', 'f'};
> > > make a string ... String s = new String(couple); // "mf"
> > >
> > > Is this what you want?
> >
> > Another approach would be, where 'b', 'a' and 'd' are chars:
> >
> > String s = b + a + d + "";
> >
> > Generally any concatenation involving a string results in a String.
> > So if you need to a sum, at the same time, you need to isolate it
> > in brackets:
> >
> > String s = b + (1+3) + d + "";
>
> I thought it would evaluate left to right, so String s = b + a + d + "";
> would be equivalent to
>
> String s = ((( b + a ) + d ) + ""; which is not what was asked for. If
you
> put the "" first it should work, though. If b, a, and d are int's that is
> what it would do. It might treat char specially.
>
> You can also create a StringBuffer, add the chars one at a time, and then
> make a String from it.
>
> -- glen
>
>
>



Relevant Pages

  • Re: How to add thousand separators
    ... First, this code is obsolete as written, because char is a dead data type and should not ... Note that both of these should be stored as string resources since they might need to be ... 18 digits for any reason. ... you have made a VERY SERIOUS DESIGN ERROR. ...
    (microsoft.public.vc.mfc)
  • Re: what is the best way of passing floats into a string
    ... I do not null-terminate as snprintf takes care of this (according to ... But the easiest way to determine the size needed to format a number, ... int length_of_representation(double n,const char* format){ ... I get a nice result of -10.000000 in my char * string. ...
    (comp.unix.programmer)
  • Re: weird problem
    ... I already told you that the comparison between an integer and a float ... to strcmpwhich expects a pointer to a string. ... And now a question about something else: why do you use floating ... int,float, char, etc. ...
    (comp.lang.c)
  • Re: why I can not write to the file after initialize the MFC in a service program
    ... you don't use char, an obsolete data type ... Why do you need an intermedate buffer to write literal strings anyway? ... For example, if AfxWinInit fails, you copy a 45-character string into a ... So you are going to try to initialize MFC EACH TIME THROUGH THE LOOP? ...
    (microsoft.public.vc.mfc)
  • Re: why I can not write to the file after initialize the MFC in a service program
    ... you don't use char, an obsolete data type ... Why do you need an intermedate buffer to write literal strings anyway? ... For example, if AfxWinInit fails, you copy a 45-character string into a ... So you are going to try to initialize MFC EACH TIME THROUGH THE LOOP? ...
    (microsoft.public.vc.mfc)