Results 1 to 4 of 4

Thread: ASC CHR conversion

  1. #1

    Thread Starter
    Junior Member random150's Avatar
    Join Date
    Mar 2001
    Location
    USA
    Posts
    30
    What are the c++ conversion functions for ASC() and CHR()

  2. #2
    Addicted Member
    Join Date
    Jan 2001
    Location
    Little Rock, Ar
    Posts
    151
    This is all I know on the subject

    Code:
    #include <iostream.h>
    #include <ctype.h>
    
    void main()
    {
    	int  i;
    	char c;
    
    
    	// typecast
    	c = (char)97; // convert to character
    	cout << c << endl;
    
    	i = (int)'a'; // convert to integer
    	cout << i << endl;
    
    	i = (int)"a"; // NOTE: "a" is not the same as 'a'
    	cout << i << endl;
    
    	// no type cast
    	c = 97;
    	cout << c << endl;
    	i = 'a';
    	cout << i << endl;
    
    	// Function
    	i = __toascii('a');// convert to integer
    	cout << i << endl;
    }

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    The character type is just an 8-bit integer. The character itself is stored as an ASCII code, so there is no need to convert it really, you just need to cast it from one type to the other so that the compiler knows how you want to deal with the information.

    I haven't seen __toascii() before, but it's probably just a macro like this:

    #define __toascii(a) (int)a
    Harry.

    "From one thing, know ten thousand things."

  4. #4

    Thread Starter
    Junior Member random150's Avatar
    Join Date
    Mar 2001
    Location
    USA
    Posts
    30
    thanx for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width