Thread: Convert ASCII to a string

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    6

    Convert ASCII to a string

    Could anyone give me insight on how this is even done?

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Huh? ASCII is a type of string encoding, just like EBCDIC & Unicode.
    If you have an array of ASCII characters, it's a string (as long as it's terminated with a '\0').
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    All variables, including char, in a computer are stored as binary values, ie, numbers. That is the purpose of the ASCII standard -- to provide a character set corresponding to numerical values.

    The bonus here is that as cpjust points out, all strings are already ASCII values:
    Code:
    char string[]="hello world";
    int i, len = strlen(string);
    for (i=0; i<len; i++) printf("%d ",string[i]);
    Check the output against your ascii table. They're the same.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  4. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  5. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM