Friday, October 31, 2014

Digest for comp.lang.c++@googlegroups.com - 5 updates in 2 topics

comp.lang.c++@googlegroups.com Google Groups
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com.
Christopher Pisz <nospam@notanaddress.com>: Oct 31 05:34PM -0500

On 10/31/2014 4:54 PM, Melzzzzz wrote:
> }
 
> Problem is that 32 bit int is not long enough, just use long long
> and all set...
 
or use C++ and drop the C style
 
#include <iostream>
 
int main()
{
long long i = 0x80000000;
std::cout << std::hex << i << std::endl;
 
return 0;
}
 
 
or if you will need the string later
 
 
#include <iostream>
#include <sstream>
 
int main()
{
long long i = 0x80000000;
std::ostringstream os;
 
os << std::hex << i;
std::cout << os.str() << std::endl;
 
return 0;
}
 
 
or at least #include <cstdlib> which has been for quite a long time now...
Geoff <geoff@invalid.invalid>: Oct 31 03:48PM -0700

On Fri, 31 Oct 2014 17:34:14 -0500, Christopher Pisz
 
>or at least #include <cstdlib> which has been for quite a long time now...
 
To be equivalent to the C code it needs to be
 
std::cout << "0x" << std::hex << i << std::endl;
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 31 03:54PM -0700

On Friday, October 31, 2014 5:43:35 PM UTC-4, Marcel Mueller wrote:
> The goal is to read an unsigned number in all common formats (decimal,
> binary, octal, hex) from a string. The string does not necessarily end
> after the number. I did not find format specifier that does the job.
 
If you cannot get one to work and need a custom one, I would be willing
to write one for you using only C.
 
Best regards,
Rick C. Hodgin
Christopher Pisz <nospam@notanaddress.com>: Oct 31 06:07PM -0500

On 10/31/2014 5:48 PM, Geoff wrote:
 
> To be equivalent to the C code it needs to be
 
> std::cout << "0x" << std::hex << i << std::endl;
 
Looks like he might want to go the other way too. If that is the case
use istringstream and operator >>
 
Just Google c++ streams in general. Much prettier than scanf and printf.
I've found doing format specifiers inside of string literals is just
plain error prone.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 31 03:11PM -0700

On Friday, October 31, 2014 3:04:48 PM UTC-4, Richard Damon wrote:
> what 'code page' you system needs to be in. In effect, this limits what
> human languages are expressible in the file, including comments and
> strings.
 
I suppose so. It is my first offering. And I am doing this alone.
They tell authors to write what they know. I suppose it works for
developers as well.
 
> U+00A0 (how it will appear in the file depends on what encoding you
> choose (UTF-8 may be the best, which would give you 0xC2, 0xA0 as a
> multi-byte character).
 
Are you ready to come on board and help me code this UNICODE support?
 
Best regards,
Rick C. Hodgin
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: