Thread: Problems displaying a char

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    3

    Unhappy Problems displaying a char

    Hi, As part of my course we have asked to do a mortgage calculator, no prolems with that but I dont seem to be able to get the programme to display a '£' i always get 'ú' instead. I have tried evry combination of char keys but cant find the '£' please help.

    Jason

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    10

    Problems displaying a char

    First of all when you talk about a computer program you don't put an "e" at the end, "programme" is used when talking about a TV programme or a programme for a play. Anyway that doesn't matter. This should work, it does for me:

    char pound = '£' ;

    but that would be pretty stupid use this:

    printf( " £ xxxx ");
    Last edited by Stinky; 11-03-2003 at 12:43 PM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > programme to display a '£' i always get 'ú' instead
    Anything outside of the 7-bit ASCII character set is at the whim of your operating system / compiler / character set mapping .....
    Details please.
    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.

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    3
    Hi thanks for the reply, the operating system is XP the compiler is visual studio.net 2003.

    Jason

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Code:
        int r, c;
        for ( r = 32 ; r < 256 ; r+=16 ) {
            printf( "%3d(%02x) ", r, r );
            for ( c = r ; c < r+16 ; c++ ) {
                printf( "%c ", c );
            }
            printf( "\n" );
        }
        printf( "Pound = £\n" );
        printf( "Pound = %c\n", 156 );
        printf( "Pound = \x9c\n" );
    This works for me, it might be different for you, but at least you should be able to find out
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The Interactive Animation - my first released C program
    By ulillillia in forum A Brief History of Cprogramming.com
    Replies: 48
    Last Post: 05-10-2007, 02:25 AM
  2. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  3. Obtaining source & destination IP,details of ICMP Header & each of field of it ???
    By cromologic in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-29-2006, 02:49 PM
  4. code condensing
    By bcianfrocca in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2005, 09:22 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM