Topic: char * ltoa( long value, char *string, int radix )
Author: "SAJILA .V" <sajilav@home.com>
Date: 2000/03/01 Raw View
Does anybody have any idea about if the function
char *ltoa( long value, char *string, int radix );
is an ANSI standard one.Any help will be appreciated!!!
Thanks!!
Sajila
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/03/01 Raw View
"SAJILA .V" wrote:
>
> Does anybody have any idea about if the function
> char *ltoa( long value, char *string, int radix );
> is an ANSI standard one.Any help will be appreciated!!!
> Thanks!!
> Sajila
No - it isn't part of standard C++. You can use std::sprintf(string,
"%ld", value) instead.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Paul Lutus" <nospam@nosite.com>
Date: 2000/03/02 Raw View
No, but there are other functions that are. Start with sprintf().
--
Paul Lutus
www.arachnoid.com
SAJILA .V <sajilav@home.com> wrote in message
news:38BC75C5.CF36FAE1@home.com...
> Does anybody have any idea about if the function
> char *ltoa( long value, char *string, int radix );
> is an ANSI standard one.Any help will be appreciated!!!
> Thanks!!
> Sajila
>
> ---
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Henrik Quintel" <HQuintel@konplan.de>
Date: 2000/03/02 Raw View
Dear <sajilav@home.com>
> Does anybody have any idea about if the function
> char *ltoa( long value, char *string, int radix );
> is an ANSI standard one.Any help will be appreciated!!!
> Thanks!!
> Sajila
In my opinion the function ltoa (long to ascii) is not part of final C++
Standard.
Greetings
Henrik quINTEL
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 2000/03/02 Raw View
In article <38BC75C5.CF36FAE1@home.com>, SAJILA .V <sajilav@home.com>
writes
>Does anybody have any idea about if the function
>char *ltoa( long value, char *string, int radix );
>is an ANSI standard one.Any help will be appreciated!!!
>Thanks!!
>Sajila
It isn't. Use sprintf() for conversions in this direction, it is then
clear who owns the string with the result in it.
Francis Glassborow Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/03/03 Raw View
Francis Glassborow <francis@robinton.demon.co.uk> writes:
|> In article <38BC75C5.CF36FAE1@home.com>, SAJILA .V <sajilav@home.com>
|> writes
|> >Does anybody have any idea about if the function
|> >char *ltoa( long value, char *string, int radix );
|> >is an ANSI standard one.Any help will be appreciated!!!
|> It isn't. Use sprintf() for conversions in this direction, it is then
|> clear who owns the string with the result in it.
On the other hand, with sprintf, it's never clear whether the output has
written beyond the end of the buffer.
If you're writing C++, use ostringstream, or with an older compiler,
ostrstream. If you're writing C, use snprintf, or with an older
compiler, you've got a problem.
--
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Dave Abrahams <abrahams@mediaone.net>
Date: 2000/03/07 Raw View
in article 86u2ipccc2.fsf@gabi-soft.de, kanze@gabi-soft.de at
kanze@gabi-soft.de wrote on 3/3/00 9:27 AM:
> On the other hand, with sprintf, it's never clear whether the output has
> written beyond the end of the buffer.
>
> If you're writing C++, use ostringstream, or with an older compiler,
> ostrstream.
Doesn't ostrstream have the same problem as sprintf?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Paul Black <paul.black@oxsemi.com>
Date: 2000/03/07 Raw View
Dave Abrahams <abrahams@mediaone.net> wrote:
>
> in article 86u2ipccc2.fsf@gabi-soft.de, kanze@gabi-soft.de at
> kanze@gabi-soft.de wrote on 3/3/00 9:27 AM:
>
> > On the other hand, with sprintf, it's never clear whether the output has
> > written beyond the end of the buffer.
> >
> > If you're writing C++, use ostringstream, or with an older compiler,
> > ostrstream.
>
> Doesn't ostrstream have the same problem as sprintf?
Not if you let ostrstream allocate the buffer.
Paul
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Jerry Coffin <jcoffin@taeus.com>
Date: 2000/03/07 Raw View
In article <B4E90DE3.24E4%abrahams@mediaone.net>,
abrahams@mediaone.net says...
[ ... ]
> > On the other hand, with sprintf, it's never clear whether the output has
> > written beyond the end of the buffer.
> >
> > If you're writing C++, use ostringstream, or with an older compiler,
> > ostrstream.
>
> Doesn't ostrstream have the same problem as sprintf?
No -- if you create an ostrstream without specifying the buffer, it
allocates one on its own, and reallocates it as needed to hold the
data you write to the stream. If you do specify the buffer into
which it will write, you're required to specify the size of the
buffer so the stream won't write any more to the buffer than you've
specified.
--
Later,
Jerry.
The universe is a figment of its own imagination.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/03/07 Raw View
Paul Black <paul.black@oxsemi.com> writes:
|> Dave Abrahams <abrahams@mediaone.net> wrote:
|> > in article 86u2ipccc2.fsf@gabi-soft.de, kanze@gabi-soft.de at
|> > kanze@gabi-soft.de wrote on 3/3/00 9:27 AM:
|> > > On the other hand, with sprintf, it's never clear whether the
|> > > output has written beyond the end of the buffer.
|> > > If you're writing C++, use ostringstream, or with an older compiler,
|> > > ostrstream.
|> > Doesn't ostrstream have the same problem as sprintf?
|> Not if you let ostrstream allocate the buffer.
Nor if you don't. The constructor with the buffer takes a second
argument with the length, and the output will fail rather than overwrite
the end of the buffer.
--
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: roger_orr@my-deja.com
Date: 2000/03/08 Raw View
In article <B4E90DE3.24E4%abrahams@mediaone.net>,
Dave Abrahams <abrahams@mediaone.net> wrote:
> in article 86u2ipccc2.fsf@gabi-soft.de, kanze@gabi-soft.de at
> kanze@gabi-soft.de wrote on 3/3/00 9:27 AM:
>
> > On the other hand, with sprintf, it's never clear whether the output
has
> > written beyond the end of the buffer.
> >
> > If you're writing C++, use ostringstream, or with an older compiler,
> > ostrstream.
>
> Doesn't ostrstream have the same problem as sprintf?
>
Only with _buggy_ implementations:- for example with MSVC6 the following
code corrupts memory:-
ostrstream os;
os.setf( ios::fixed, ios::floatfield );
os << 1e32;
I believe it is because implementation buffers (used for the conversion
of the number to a string) overflow.
The bug doesn't appear with ostringstream - presumably implemented
differently.
Roger Orr
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]