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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing characters into bit strings and bit strings back into charact

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to change a string of characters to a bit string, generate some random errors that change the original character string and change the bit string back to the original character string.

Any help appreciated
 
well, you need to do it with 8 bit values, ie chars and it would look something like

void printStringInBinary(char* str)
{
char* ptr = str;
while(*ptr)
{
for(int i = 7;i>=0;i--)
{
int val = (*ptr & 1<<i ? 1:0);
cout<<val;
}
ptr++;
}
}

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top