| delorie.com/archives/browse.cgi | search |
| From: | Martin Ambuhl <mambuhl AT earthlink DOT net> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Converting numbers to strings |
| Date: | Sun, 09 May 1999 21:01:29 -0400 |
| References: | <HhOCsDAf$YN3EwuI AT dunvegan1 DOT demon DOT co DOT uk> <37359AD7 DOT 8FC41504 AT earthlink DOT net> <pDrp0GAJQaN3EwoN AT dunvegan1 DOT demon DOT co DOT uk> |
| X-Posted-Path-Was: | not-for-mail |
| X-Accept-Language: | en |
| X-ELN-Date: | 10 May 1999 01:00:20 GMT |
| X-ELN-Insert-Date: | Sun May 9 18:05:10 1999 |
| Organization: | Nocturnal Aviation |
| Lines: | 29 |
| Mime-Version: | 1.0 |
| NNTP-Posting-Host: | dialup-209.246.103.161.newyork2.level3.net |
| Message-ID: | <37362FE9.534C71DB@earthlink.net> |
| X-Mailer: | Mozilla 4.51 [en] (Win95; I) |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Paul Richards wrote:
>
> Martin Ambuhl writes,
> >This extremely ugly BASIC construction should make you appreciate the much
> >derided-by-C++-advocates sprintf function:
> Yeah, I've got a lot of BASIC bad habits. Took me ages to put code into
> functions instead of just one big main();
> :)
>
> >#include <cstdio>
> >char *filename;
> >int i;
> > sprintf(filename,"pic%d.bmp",i);
> Thanks a huge amount. What about leading zero's and stuff so that I
> get:
> pic001.bmp
> pic002.bmp
> ....
> pic067.bmp
> ...
> pic245.bmp
> ...
> etc??
sprintf(filename,"pic%03d.bmp",i);
--
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |