Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How do i display a '' sign with puts of printf? (http://www.go4expert.com/forums/i-display-sign-printf-t16928/)

Player 15Apr2009 14:37

How do i display a '' sign with puts of printf?
 
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);
}

asadullah.ansari 16Apr2009 09:31

Re: How do i display a '' sign with puts of printf?
 
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;
}


Player 16Apr2009 13:58

Re: How do i display a '' sign with puts of printf?
 
Quote:

Originally Posted by asadullah.ansari (Post 45745)
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;
}


Thanks for this :)

Player 16Apr2009 14:38

Re: How do i display a '' sign with puts of printf?
 
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.

asadullah.ansari 16Apr2009 15:24

Re: How do i display a '' sign with puts of printf?
 
Only you have to include stdio.h

Player 16Apr2009 15:59

Re: How do i display a '' sign with puts of printf?
 
Quote:

Originally Posted by asadullah.ansari (Post 45770)
Only you have to include stdio.h

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:

asadullah.ansari 16Apr2009 16:05

Re: How do i display a '' sign with puts of printf?
 
Can you tell me which compiler you are using...

Player 16Apr2009 16:40

Re: How do i display a '' sign with puts of printf?
 
Quote:

Originally Posted by asadullah.ansari (Post 45778)
Can you tell me which compiler you are using...

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.

asadullah.ansari 16Apr2009 18:38

Re: How do i display a '' sign with puts of printf?
 
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;
}


Player 16Apr2009 18:45

Re: How do i display a '' sign with puts of printf?
 
Quote:

Originally Posted by asadullah.ansari (Post 45783)
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;
}


That's it! Thanks for your help with this. I thought i was going mad lol


All times are GMT +5.5. The time now is 22:22.