ASCII Problem

This is a discussion on ASCII Problem within the C Programming forums, part of the General Programming Boards category; i want to write the symbol of Degrees in Centigrade "180oC', and i use ASCII code to write the "o" ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    2

    ASCII Problem

    i want to write the symbol of Degrees in Centigrade "180oC', and i use ASCII code to write the "o" symbol, but ...

    printf( "180%cC", chr(167) );

    when i execute the c program, the error say "undefined reference to `chr'", what can i do ??

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Don't put the chr(). Use this:
    printf("180%cCCC",167);

  3. #3
    Ethereal Raccoon Procyon's Avatar
    Join Date
    Aug 2001
    Posts
    189
    The correct typecast is (char), not chr(). But you don't need it here anyway; the output format (as a character rather than a numeral) is taken care of by the format specifier %c in printf().

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2

    Another Problem

    if i use this "printf("180%cC",167);"

    the output in dos mode is "180íŠ", has a chinese word behind 180,
    but if i copy the output to windows, it's OK, can see the symbol, why ?? what can i do ??

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Try making a variable and using that.

    int symbol=167;
    printf("180%cC",symbol);

    That might work. Doing it how I said earlier worked for me.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    > i want to write the symbol of Degrees in Centigrade
    It's not an ASCII character (these run from 32 to 127). Anything else is subject to the vagaries of compilers / operating systems / fonts.

    Unless you're using UNICODE in an environment which supports it, then you might fare better.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Maybe 176.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. array input/output problem
    By glowstick in forum C Programming
    Replies: 1
    Last Post: 09-10-2002, 07:56 PM

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