Be a Supporter!

how to get the '£' to output in c++

  • 411 Views
  • 14 Replies
New Topic Respond to this Topic
thecoshman
thecoshman
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
how to get the '£' to output in c++ 2006-08-29 12:44:52 Reply

I am currently at the level of consol apps, though im just making sure i can do the basics good and proper befor i try anything harder.

how can you get the '£' sign to output. if i just go cout << "£"; i get a u with a bit above it. i no that in pascal you need to use a special command for such things like, so the has to be a c++ equivlent.

I have tried searching google, but aparently the pound sign is this '#'. I always thought that a '#' was known as a hash?

any one want to fill me in on this please?

0x41
0x41
  • Member since: Dec. 30, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-29 12:50:02 Reply

At 8/29/06 12:44 PM, thecoshman wrote: how can you get the '£' sign to output. if i just go cout << "£"; i get a u with a bit above it. i no that in pascal you need to use a special command for such things like, so the has to be a c++ equivlent.

You need to output it's ASCII code
cout<<(char)156;

thecoshman
thecoshman
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-29 13:09:27 Reply

thank you, do you know where i can get some sort of table that list the common ones of these?

and how come you cant just use some sort of escape thing, like the newline one? that stupid!

elbekko
elbekko
  • Member since: Jul. 23, 2004
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-29 13:16:05 Reply

http://www.lookuptables.com/


"My software never has bugs. It just develops random features. " - Unknown

[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]

BBS Signature
NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to how to get the '£' to output in c++ 2006-08-29 13:22:10 Reply

At 8/29/06 01:16 PM, elbekko wrote: http://www.lookuptables.com/

It's funny, there is a alias for that domain (or perhaps your link is a alias for this one):

http://asciitable.com/

elbekko
elbekko
  • Member since: Jul. 23, 2004
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-29 13:25:04 Reply

At 8/29/06 01:22 PM, Nino_JoJ wrote:
At 8/29/06 01:16 PM, elbekko wrote: http://www.lookuptables.com/
It's funny, there is a alias for that domain (or perhaps your link is a alias for this one):

http://asciitable.com/

I know, I usually use asciitable.com, but it redirects me to that page ;)


"My software never has bugs. It just develops random features. " - Unknown

[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]

BBS Signature
JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-29 13:25:58 Reply

At 8/29/06 01:09 PM, thecoshman wrote: thank you, do you know where i can get some sort of table that list the common ones of these?

and how come you cant just use some sort of escape thing, like the newline one? that stupid!

Because escaping a character isn't the same as outputting a special character. There's no "new line" character so you need to escape the letter n, it's not a shortcut to output something, it's an escape.

0x41
0x41
  • Member since: Dec. 30, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-29 13:39:11 Reply

At 8/29/06 01:25 PM, JeremysFilms wrote:
Because escaping a character isn't the same as outputting a special character. There's no "new line" character so you need to escape the letter n, it's not a shortcut to output something, it's an escape.

The newline character is defined is 0x0A so you could do
cout<<"This is "<<(char)0x0A<<"broken up into"<<(char)0x0A<<"three lines";
and have it work correcetly.

CronoMan
CronoMan
  • Member since: Jul. 19, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-30 05:08:00 Reply

You should use unicode instead, cout << "\u00A3", or it might differ from locale to locale


"no sound in ass"

CyberLemming
CyberLemming
  • Member since: Aug. 9, 2005
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-30 07:47:50 Reply

or you could use std::endl .

thecoshman
thecoshman
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-30 10:01:15 Reply

At 8/30/06 07:47 AM, CyberLemming wrote: or you could use std::endl .

hmmm

std::endl

or

\n

i know wich i will be using

thecoshman
thecoshman
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-30 11:37:13 Reply

with the (char)156, is there a way of putting it into text with out having to go

cout << "a syntax error costs " << (char)156 << "10 to fix!!!!";

if you know what i mean, is that the only way you can putt it in there.

0x41
0x41
  • Member since: Dec. 30, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-30 12:35:55 Reply

At 8/30/06 05:08 AM, CronoMan wrote: You should use unicode instead, cout << "\u00A3", or it might differ from locale to locale

That won't work. You need to use WriteConsoleW if you want to write unicode to a console, and even then it's kind of pointless since you lose portability.

At 8/30/06 11:37 AM, thecoshman wrote: with the (char)156, is there a way of putting it into text with out having to go

cout << "a syntax error costs " << (char)156 << "10 to fix!!!!";

if you know what i mean, is that the only way you can putt it in there.

I guess you can do something like this -
#define b (char)156

int main()
{
cout<<"A syntax error costs "<<b<<"10 to fix!!!\n";
return 0;
}

CyberLemming
CyberLemming
  • Member since: Aug. 9, 2005
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-30 12:49:53 Reply

At 8/30/06 10:01 AM, thecoshman wrote: i know wich i will be using

good for you, now why don't you hurry to your english class? seems like you need it.

CronoMan
CronoMan
  • Member since: Jul. 19, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to how to get the '£' to output in c++ 2006-08-31 10:14:33 Reply

Hello? still using (char)156? Use unicode or it will get fucked up on other locales


"no sound in ass"