| delorie.com/archives/browse.cgi | search |
| From: | "Duncan Coutts" <Duncan DOT Coutts AT dial DOT pipex DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Numbers to Strings |
| Date: | Wed, 22 Sep 1999 23:03:59 +0100 |
| Organization: | UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom |
| Lines: | 24 |
| Message-ID: | <7sbk0v$6n5$2@lure.pipex.net> |
| References: | <7s0kea$qr6$1 AT rohrpostix DOT uta4you DOT at> <37E3F6A0 DOT B80A0505 AT armenia DOT multi DOT net DOT co> |
| NNTP-Posting-Host: | aa177.du.pipex.com |
| X-Trace: | lure.pipex.net 938038111 6885 193.130.240.177 (22 Sep 1999 22:08:31 GMT) |
| X-Complaints-To: | abuse AT uk DOT uu DOT net |
| NNTP-Posting-Date: | 22 Sep 1999 22:08:31 GMT |
| X-Newsreader: | Microsoft Outlook Express 4.72.2106.4 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.2106.4 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
>> Hi, I'm quite new to programming in C++ and I have got a question about >> strings: How can I convert a number into a string, > >you can use itoa/ftoa to convert from Integer to Ascii. > >but it is easier using sprintf. > >sprintf ( the_string, "%i", the_integer ); If you use the standard functionality of C++ rather than C then you should use std::string which I'm sure has functions for creating a string that represents a number. I don't know for certain but I bet the string class has a constructor taking an int. If all you need to do is output it to a stream then the conversion is automatic.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |