The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-23-2004
01doublehelix10 01doublehelix10 is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 2
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.
  #2 (permalink)  
Old 09-24-2004
01doublehelix10 01doublehelix10 is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 2
nope just a hobby i graduated from school later year.
  #3 (permalink)  
Old 09-24-2004
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,748
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;   
}
You can also use sscanf().
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0