From chemistry-request@server.ccl.net Wed Mar 13 15:10:08 2002
Received: from donkeykong.gpcc.itd.umich.edu (smtp@[141.211.2.163])
	by server.ccl.net (8.11.6/8.11.0) with ESMTP id g2DKA8p09520
	for <chemistry@ccl.net>; Wed, 13 Mar 2002 15:10:08 -0500
Received: from amidar.gpcc.itd.umich.edu (amidar.gpcc.itd.umich.edu [141.211.2.209])
        by donkeykong.gpcc.itd.umich.edu (8.8.8/4.3-mailhub) with ESMTP id PAA26781; Wed, 13 Mar 2002 15:10:02 -0500 (EST)
Received: from localhost (manojp@localhost)
	by amidar.gpcc.itd.umich.edu (8.9.1a/5.1-client) with ESMTP id PAA02456; Wed, 13 Mar 2002 15:10:02 -0500 (EST)
Precedence: first-class
Date: Wed, 13 Mar 2002 15:10:02 -0500 (EST)
From: Manoj Pal <manojp@umich.edu>
X-X-Sender:  <manojp@amidar.gpcc.itd.umich.edu>
To: Krzysztof Radacki <K.Radacki@ic.ac.uk>
cc: CCL <chemistry@ccl.net>
Subject: Re: CCL:small linux/c++ question.
In-Reply-To: <000701c1caa4$3ae3a7d0$0300a8c0@attbi.com>
Message-ID: <Pine.SOL.4.33.0203131435110.21785-100000@amidar.gpcc.itd.umich.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi Krzysztof,

You can do it with a couple of lines of code in C/C++:

----------------------------------------------------------
 char string_after_conversion[10000]; //make it big
 int int_to_convert;

 //read an int in int_to_convert

 sprintf(string_after_conversion, "%d", int_to_convert);
----------------------------------------------------------

 printf("%s\n",string_after_conversion); //verify...


bye,
.====================================================================.
|                                |                                   |
|  Manoj Pal                     |   Even a stopped clock tells      |
|  Graduate Student              |   the right time twice a day      |
|  Department of Chemistry       |                                   |
|  University of Michigan        |                                   |
|  Ann Arbor, Michigan           |   http://www.manojpal.cjb.net     |
|  USA                           |   Email: pal_m@mailcity.com       |
|                                |                                   |
'===================================================================='


On Wed, 13 Mar 2002, Mark Thompson wrote:

>
> Dear Krzysztof,
>
> I've appended an implementation that I've used in the past.  It creates the
> string in inverted order and reverses it at the end.  All the usual caveats
> about making sure the argument s[] is big enough apply...
>
> Mark
>
> =================================
> Mark Thompson, Ph.D.
> Planaria Software
> Seattle, WA.
> http://www.arguslab.com
> =================================
>
>
> void Itoa (int n, char s[])
> {
>   int   i, j, c, sign;
>
>   if ((sign = n) < 0) {n = -n;}
>
>   i = 0;
>
>   do
>   {
>     s[i++] = (n % 10) + '0';
>   } while ((n /= 10) > 0);
>
>
>   if (sign < 0) {s[i++] = '-';}
>
>   s[i] = '\0';
>
>   for (i = 0, j = strlen(s) - 1;  i < j; i++, j--)
>   {
>     c    = s[i];
>     s[i] = s[j];
>     s[j] = c;
>   }
> }
>
>
> > -----Original Message-----
> > From: Computational Chemistry List [mailto:chemistry-request@ccl.net]On
> > Behalf Of Krzysztof Radacki
> > Sent: Wednesday, March 13, 2002 3:43 AM
> > To: CCL
> > Subject: CCL:small linux/c++ question.
> >
> >
> > Dear CCL'ers
> > I have a little bit out of topic question.
> > Currently I'm translating my program from Borland C++
> > to gcc and I can't find a function itoa in gcc (it
> > converts integer to string).
> > I would be quite happy if someone could explaine me how
> > to do it in gcc.
> >
> > MfG
> > Krzysztof
> >
> > p.s.
> > because it's realy out-of-topic maybe better if answer
> > would be addressed directly to my e-mail not to ccl.
> >
> >
> > --
> > Dr. K.Radacki
> > Department of Chemistry
> > Catalysis and Advanced Materials Section
> > Imperial College, London
> >
> > CHEMISTRY@ccl.net -- To Everybody  | CHEMISTRY-REQUEST@ccl.net --
> > To Admins
> > CHEMISTRY-SEARCH@ccl.net -- archive search    |    Gopher:
> > gopher.ccl.net 70
> > Ftp: ftp.ccl.net  |  WWW: http://www.ccl.net/chemistry/   | Jan:
> > jkl@ccl.net
> >
> >
> >
> >
> >
> >
>
>
> -= This is automatically added to each message by mailing script =-
> CHEMISTRY@ccl.net -- To Everybody  | CHEMISTRY-REQUEST@ccl.net -- To Admins
> MAILSERV@ccl.net -- HELP CHEMISTRY or HELP SEARCH
> CHEMISTRY-SEARCH@ccl.net -- archive search    |    Gopher: gopher.ccl.net 70
> Ftp: ftp.ccl.net  |  WWW: http://www.ccl.net/chemistry/   | Jan: jkl@ccl.net
>
>
>
>
>





