Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,630 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,064 people online right now. Registration is fast and FREE... Join Now!




Conversions - ASCII, Hex, Binary

 
Reply to this topicStart new topic

Conversions - ASCII, Hex, Binary

renzo666
post 25 Mar, 2006 - 10:39 PM
Post #1


New D.I.C Head

*
Joined: 25 Mar, 2006
Posts: 1


My Contributions


Anyone know how to convert ASCII to Hexadecimal and Binary, just like this.


"Hello this is a test"

Hex:

48 65 6c 6c 6f 20 74 68 69 73 20 69 73 20 61 20 74 65 73 74

Binary:

01001000 01100101 01101100 01101100 01101111 00100000 01110100 01101000 01101001 01110011 00100000 01101001 01110011 00100000 01100001 00100000 01110100 01100101 01110011 01110100 00100000 01100011 01101111 01101110 01110110 01100101 01110010 01110100 01110011 00100000 01110100 01101111 00001101 00001010 00001101 00001010
User is offlineProfile CardPM

Go to the top of the page

Dark_Nexus
post 26 Mar, 2006 - 01:47 AM
Post #2


or something bad...real bad.

Group Icon
Joined: 2 May, 2004
Posts: 1,309



Thanked 2 times

Dream Kudos: 625
My Contributions


the person who made this is probably the smartest guy i know:

http://code.dreamincode.net/snippet30.htm
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 26 Mar, 2006 - 06:52 AM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


QUOTE(Dark_Nexus @ 26 Mar, 2006 - 03:39 AM)
the person who made this is probably the smartest guy i know:

Hardcore sexy, too.
User is offlineProfile CardPM

Go to the top of the page

poke_blade
post 27 Mar, 2006 - 02:19 AM
Post #4


New D.I.C Head

*
Joined: 26 Feb, 2006
Posts: 21



Dream Kudos: 10
My Contributions


How about these codes which prints a alpha character into bin/hex/oct
CODE

void show_in_binary(unsigned char n)
{
int i,amask;
for(i=7;i>=0;i--)
{
amask=1<<i;
(n&amask)==0?printf("0"):printf("1");
}
}


CODE

void show_in_hex(unsigned char n)
{
printf("%lx",(long)n);
}


CODE

void show_in_oct(unsigned char n)
{
printf("%lo",(long)n);
}
User is offlineProfile CardPM

Go to the top of the page

Dark_Nexus
post 28 Mar, 2006 - 09:26 AM
Post #5


or something bad...real bad.

Group Icon
Joined: 2 May, 2004
Posts: 1,309



Thanked 2 times

Dream Kudos: 625
My Contributions


those is some mad codes dogg
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 03:58AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month