1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do i display a '£' sign with puts of printf?

Discussion in 'C' started by Player, Apr 15, 2009.

  1. Player

    Player New Member

    Joined:
    Aug 3, 2007
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    Hi all.

    As the title says. Not sure where i'm going wrong.

    #include <stdio.h>

    int main()
    {
    printf("How do i display a pound sign? It always comes out like this \'£\'.\n");
    printf("I have tried it like this too but still it makes no difference %c.\n",'£');
    printf("I have looked at the ASCII but can't find a pound sign.\n");
    puts("Even puts won't do it! £££££££");
    return(0);
    }
     
  2. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    Pound sign is defined in unicode & in latin that is 163. It's ISO-8859-8 standard.


    Code:
    int main()
    {
       char ch=163 ;
       printf("%c",ch);  
       return 0;
    }
     
  3. Player

    Player New Member

    Joined:
    Aug 3, 2007
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for this :)
     
  4. Player

    Player New Member

    Joined:
    Aug 3, 2007
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    It's displaying a 'c' type character with a bit above it. This was the same as i was getting before. Is there a another header i should be using? I'm just using stdio.
     
  5. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    Only you have to include stdio.h
     
  6. Player

    Player New Member

    Joined:
    Aug 3, 2007
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    When i compile and run your code i still get the same result. It displays a c type character. I don't understand it :nonod:
     
  7. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    Can you tell me which compiler you are using...
     
  8. Player

    Player New Member

    Joined:
    Aug 3, 2007
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    DEV C++ V4.9.9.2.

    As you can tell i'm a beginner. I didn't really know which compiler to use so tried a few out and found this to be the most user friendly.
     
    Last edited: Apr 16, 2009
  9. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    Yes!! You are right... On DEV C++ V4.9.9.2. compiler Pound sign has ascii value of 156 and gcc has 163.
    So Now you can try this.

    Code:
    #include<stdio.h>
    #include<conio.h>
    
    int main()
    {
       char ch=156;
       printf("%c",ch); 
       getch(); 
       return 0;
    }
     
  10. Player

    Player New Member

    Joined:
    Aug 3, 2007
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    That's it! Thanks for your help with this. I thought i was going mad lol
     

Share This Page