[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Konvertera intar.



Mads Bondo Dydensborg wrote:

> On Wed, 19 Jan 2000, Joachim Holst (QCS) wrote:
>
> > Hejsan !
> >
> > Sitter och behöver konvertera en int till en sträng.
> >
> > Tyvärr, så finns visst inte itoa funktionen i Linux så jag måste väl skriva en egen.
> > Någon som har exempel på hur man gör ??
> >
> > Står helt still i min skalle...
>
> Check sprinft
>
> noget i den her stil:
>
> char buf[512];
> sprintf(buf, "%i", 42);

Et alternativt forslag under g++ (egcs/gcc) er:
#include <strstream.h>
extern "C++" {
    ...
    strstream string_as_a_stream;
    string_as_a_stream << 42;
    ...
}

Den åbenlyse fordel er den pædagogiske syntaks.

Personlig vil jeg dog indtil STL og dermed std::basic_stringstream<.> er blevet
implementeret i egcs/gcc fortsætte med at bruge sprintf(.) som Mads Bondo Dydensborg
anbefaler.

Indtil en tilfredstillende STL implementation foreligger er morphemet "sprint-f" stadig i
særdeleshed gældendende!


Nils Åke Ljunggren.
svansker.




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *