about accessing special symbols

This is a discussion on about accessing special symbols within the C Programming forums, part of the General Programming Boards category; Hi, would you guys know how to actually print out symbols like: pi, theta and etc? thank you...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    31

    about accessing special symbols

    Hi, would you guys know how to actually print out symbols like:
    pi, theta and etc? thank you

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,157
    If you're talking about the standard characters above 128 decimal, two main ways:
    1) #define charname 0xFF
    replace FF with the hex value of the character in question and display it as a character.
    putchar(charname);
    printf("%c", charname);

    2) printf("\xFF\xFF...");
    of course replace FF with the value of the character to output
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    Would you know where I could get the hex value for the special characters?

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Anything above the ASCII defined stuff is different on every OS. You're probably out of luck if you want to display pi and such, unless you display them as a graphic (which would require a library)
    Away.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by godhand
    Would you know where I could get the hex value for the special characters?
    As noted, the extended characters aren't guaranteed, but you might look here for an idea of how they work:
    http://www.asciitable.com/
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    Thanks Hammer!

  7. #7
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    Code:
    printf("%c\n%c %cd%c\n%c\n",244,179,227,227,245);
    and you can do things like:
    Code:
    #define YEN 157
    #define F_FUNC 159
    #define HALF 171
    #define FOURTH 172
    #define PI_SYM 227
    #define PHI 232
    #define OMEGA 234
    #define MU 230
    #define BETA 225
    #define ALPHA 224
    #define INFINITY 236
    #define SQRRT 251
    #define SQRD 253
    #define ABOUT 247
    #define DIV 246
    #define PLUS_MINUS 241
    #define LESS_EQUAL 242
    #define GREAT_EQUAL 243
    #define INTEGRAL_TOP 244
    #define INTEGRAL_MID 179
    #define INTEGRAL_BOT 245
    to simplify it

    __ON WINDOWS!__

    -LC
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  8. #8
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    It happens that my Debian linux does not have extended ascii characters, do any linux guru here knows how I can somehow add the extended ascii to my linux?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux Putting my children to sleep with futex!?
    By Abs in forum Linux Programming
    Replies: 18
    Last Post: 02-12-2009, 05:43 PM
  2. Replies: 7
    Last Post: 02-02-2009, 06:27 AM
  3. Trouble with Windows/DirectX programming
    By bobbelPoP in forum Windows Programming
    Replies: 16
    Last Post: 07-08-2008, 02:27 AM
  4. Strange error?
    By MrLucky in forum C++ Programming
    Replies: 5
    Last Post: 02-04-2006, 02:01 PM
  5. symbols, no symbols, symbols ...
    By pavmarc in forum Linux Programming
    Replies: 0
    Last Post: 08-23-2005, 12:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21