Computing.Net > Forums > Programming > How to convert string to a binary

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to convert string to a binary

Reply to Message Icon

Name: Paul
Date: February 22, 2002 at 13:45:29 Pacific
Comment:

I need to convert a string to binary in C++. I will prompt the user for input of a string. For example if he enters "Hello". What i need to do convert that string to binary form. I need that binary to perform a crc-16 check on the binary. i have done that part, i just need to convert a string to binary. Help please



Sponsored Link
Ads by Google

Response Number 1
Name: oh come on
Date: February 22, 2002 at 14:11:37 Pacific
Reply:

thats so easy.

int mask=0;

for(i=size;i>=0;i--)
{
if((word>>i)& mask)
printf("1");
else
printf("0");
}

I gave you the answer!!!


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: How to convert string to a binary

How to convert a fil a to PDF www.computing.net/answers/programming/how-to-convert-a-fil-a-to-pdf/6928.html

how to convert chars to int www.computing.net/answers/programming/how-to-convert-chars-to-int/11828.html

How to write html code in perl? www.computing.net/answers/programming/how-to-write-html-code-in-perl/12668.html