Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Needed : Ascii to Binary Function???

Status
Not open for further replies.

LiquidBinary

Programmer
Jul 27, 2001
148
US
I know there is a function in the standard lib. that converts ascii to binary and vice versa...??? What is it? mlg400@blazemail.com
 
char* endptr;
int binary = strtol("1000",endptr,2);

will convert ascii (1's and 0's) to a value

for the conversion back to ascii i dont know of a function but i have used

char strBinary[32];
for(int i = 0,int j = 31;i<32;i++,j--)
{
strBinary[j] = (binary & 1<<i ? '1':'0');
}



Good luck... and if you find an easier method to go from value to binary let me know please.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top