![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading a binary file in text or ASCII format | Nagendra | High Level Programming | 3 | 12-03-2008 06:11 PM |
| How to convert binary Unix file to text | user12345 | UNIX for Dummies Questions & Answers | 5 | 11-10-2006 06:53 AM |
| Binary data to text file conversion | auro123 | UNIX for Dummies Questions & Answers | 1 | 12-26-2005 06:48 AM |
| is it text or binary | avnerht | Shell Programming and Scripting | 1 | 06-23-2004 01:40 PM |
| Binary to text format conversion | manjunath | High Level Programming | 5 | 11-14-2002 01:10 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Binary to Text Convertor
Hey Im starting out in C just recently and Im needing a string that converts binary to text, The only way i know of doing this without knowledge of C entirely. Is Making a sorta of library of the entire alphabet in binary for the program to select the text from it to display a sentence. If that makes any sense, anyways any help would be appreciated as would some tutorials on these matters.
|
|
||||
|
here is one way - using strtol()
Code:
#include <stdlib.h>
/* assume two hex chars per ascii value */
void hex2ascii(char *dest, char *src){
char tmp[4]={0x0};
char **ptr=NULL,
*buf=dest;
*buf=0x0;
if(*src){
for(int i=0;src[i];i+=2){
strncpy(tmp,&src[i],2);
sprintf(tmp,"%c",strtol(tmp,ptr,16) );
*buf++=tmp[0];
}
}
*buf=0x0;
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|