Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: How to show a string with hexadecimal integer included?

Reply
Thread Tools

Re: How to show a string with hexadecimal integer included?

 
 
Derk Gwen
Guest
Posts: n/a
 
      06-25-2003
Christopher Culver <(E-Mail Removed)> wrote:
# I have a string which should include a hexadecimal number. I've tried %x
# like this:
#
# printf("This is a hex number: %x", hexNumber)
#
# but this results in only the minimum number of digits being displayed,
# i.e. "7e" instead of "0x007e". Is there anything I can use in place of %x
# which will display the fully qualified hexadecimal number?

%04x

--
Derk Gwen http://derkgwen.250free.com/html/index.html
But I do believe in this.
 
Reply With Quote
 
 
 
 
Zoran Cutura
Guest
Posts: n/a
 
      06-26-2003
Derk Gwen <(E-Mail Removed)> wrote:
> Christopher Culver <(E-Mail Removed)> wrote:
> # I have a string which should include a hexadecimal number. I've tried %x
> # like this:
> #
> # printf("This is a hex number: %x", hexNumber)
> #
> # but this results in only the minimum number of digits being displayed,
> # i.e. "7e" instead of "0x007e". Is there anything I can use in place of %x
> # which will display the fully qualified hexadecimal number?
>
> %04x


That will be missing the leading 0x part. Either add it manually to the
above or use %#04x instead.
--
Z ((E-Mail Removed))
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond
 
Reply With Quote
 
 
 
 
Martin Ambuhl
Guest
Posts: n/a
 
      06-26-2003
Zoran Cutura <(E-Mail Removed)> wrote (26 Jun 2003) in
news:bde0vo$ntq$(E-Mail Removed)-felb.debis.de / comp.lang.c:

> Derk Gwen <(E-Mail Removed)> wrote:
>> Christopher Culver <(E-Mail Removed)>
>> wrote: # I have a string which should include a hexadecimal number.
>> I've tried %x # like this:
>> #
>> # printf("This is a hex number: %x", hexNumber)
>> #
>> # but this results in only the minimum number of digits being
>> displayed, # i.e. "7e" instead of "0x007e". Is there anything I can
>> use in place of %x # which will display the fully qualified
>> hexadecimal number?
>>
>> %04x

>
> That will be missing the leading 0x part. Either add it manually to
> the above or use %#04x instead.


I think you mean %#06x. Count the characters: 0x007e


--
Martin Ambuhl
Returning soon to the
Fourth Largest City in America
 
Reply With Quote
 
Zoran Cutura
Guest
Posts: n/a
 
      06-26-2003
Martin Ambuhl <(E-Mail Removed)> wrote:
> Zoran Cutura <(E-Mail Removed)> wrote (26 Jun 2003) in
> news:bde0vo$ntq$(E-Mail Removed)-felb.debis.de / comp.lang.c:
>
>> Derk Gwen <(E-Mail Removed)> wrote:
>>> Christopher Culver <(E-Mail Removed)>
>>> wrote: # I have a string which should include a hexadecimal number.
>>> I've tried %x # like this:
>>> #
>>> # printf("This is a hex number: %x", hexNumber)
>>> #
>>> # but this results in only the minimum number of digits being
>>> displayed, # i.e. "7e" instead of "0x007e". Is there anything I can
>>> use in place of %x # which will display the fully qualified
>>> hexadecimal number?
>>>
>>> %04x

>>
>> That will be missing the leading 0x part. Either add it manually to
>> the above or use %#04x instead.

>
> I think you mean %#06x. Count the characters: 0x007e


Yes I meant 6 not 4 (which I cut'n'pasted fro the original posting).

I think my brain needs a fart update. I'm producing to much waste in the
past.

--
Z ((E-Mail Removed))
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Change a string to an integer, report an error if the string does not represent an integer? Randy Kramer Ruby 12 10-25-2007 09:56 PM
Converting negative integer to octal/hexadecimal jaks.maths@gmail.com C Programming 15 06-23-2006 12:06 PM
Re: How to show a string with hexadecimal integer included? bd C Programming 0 06-26-2003 05:10 PM
Re: How to show a string with hexadecimal integer included? Martin Ambuhl C Programming 1 06-26-2003 01:14 PM



Advertisments