Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › How to use a '£' Sign in C++?
New Posts  All Forums:Forum Nav:

How to use a '£' Sign in C++?

post #1 of 7
Thread Starter 
So I've used the #include library.

I need to add a pound sign within the following bit of code:
cout << "The cost of shipment over" << " " << miles << " " << "miles is" << " " << cost << endl;

I need a pound symbol to be shown when the contents of the variable "cost" is revealed. Right now it revealed the number without the pound symbol.

Thank you.
X79-GCN
(22 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz HT GIGABYTE GA-X79-UP4 AMD R9-290X GEil Evo Potenza DDR3 2400MHz CL10 (4x4GB) 
Hard DriveCoolingCoolingCooling
Samsung 840 Pro 120GB EK Supremacy (CPU) NF F12's P/P (360 Rad)  NF A14's (420 Rad)  
CoolingCoolingCoolingCooling
XSPC Chrome Compression Fittings EK RES X3 150 Primochill PremoFlex Advanced LRT Clear 1/2 ID EK-FC (R9 290X) 
CoolingCoolingCoolingOS
EK D5 Vario Top-X  Phobya G-Changer V2 360mm Phobya G-Changer V2 420mm Win 10 x64 Pro 
MonitorKeyboardPowerCase
BenQ XR3501 35" Curved Corsair Vengeance K90 Seasonic X-1250 Gold (v2) Corsair 900D 
MouseAudio
Logitech G400s Senn HD 598 
  hide details  
Reply
X79-GCN
(22 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz HT GIGABYTE GA-X79-UP4 AMD R9-290X GEil Evo Potenza DDR3 2400MHz CL10 (4x4GB) 
Hard DriveCoolingCoolingCooling
Samsung 840 Pro 120GB EK Supremacy (CPU) NF F12's P/P (360 Rad)  NF A14's (420 Rad)  
CoolingCoolingCoolingCooling
XSPC Chrome Compression Fittings EK RES X3 150 Primochill PremoFlex Advanced LRT Clear 1/2 ID EK-FC (R9 290X) 
CoolingCoolingCoolingOS
EK D5 Vario Top-X  Phobya G-Changer V2 360mm Phobya G-Changer V2 420mm Win 10 x64 Pro 
MonitorKeyboardPowerCase
BenQ XR3501 35" Curved Corsair Vengeance K90 Seasonic X-1250 Gold (v2) Corsair 900D 
MouseAudio
Logitech G400s Senn HD 598 
  hide details  
Reply
post #2 of 7
Not great at C++ but the easy way is to put it in <<"£" <<

but i guess you already know that so my answer is useless lol
Work PC
(4 items)
 
Home PC
(4 items)
 
 
CPUMotherboardGraphicsRAM
4770k Asus SABERTOOTH Z87 290 16 trident  
CPUMotherboardGraphicsRAM
8350 gigabyte 990fxa 660 16gb trident 
  hide details  
Reply
Work PC
(4 items)
 
Home PC
(4 items)
 
 
CPUMotherboardGraphicsRAM
4770k Asus SABERTOOTH Z87 290 16 trident  
CPUMotherboardGraphicsRAM
8350 gigabyte 990fxa 660 16gb trident 
  hide details  
Reply
post #3 of 7
cout<<(char) 163<<end;

the GBP symbol is the 163rd symbol in the ASCII table
post #4 of 7
//show pound sign in c++

char pound=156;

cout << “This will cost ” <<pound << “5.00″ ;
Work PC
(4 items)
 
Home PC
(4 items)
 
 
CPUMotherboardGraphicsRAM
4770k Asus SABERTOOTH Z87 290 16 trident  
CPUMotherboardGraphicsRAM
8350 gigabyte 990fxa 660 16gb trident 
  hide details  
Reply
Work PC
(4 items)
 
Home PC
(4 items)
 
 
CPUMotherboardGraphicsRAM
4770k Asus SABERTOOTH Z87 290 16 trident  
CPUMotherboardGraphicsRAM
8350 gigabyte 990fxa 660 16gb trident 
  hide details  
Reply
post #5 of 7
Thread Starter 
Quote:
Originally Posted by TLCH723 View Post

cout<<(char) 163<<end;

the GBP symbol is the 163rd symbol in the ASCII table

Quote:
Originally Posted by AnnoyinDemon View Post

//show pound sign in c++

char pound=156;

cout << “This will cost ” <<pound << “5.00″ ;

Thanks guy's.
X79-GCN
(22 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz HT GIGABYTE GA-X79-UP4 AMD R9-290X GEil Evo Potenza DDR3 2400MHz CL10 (4x4GB) 
Hard DriveCoolingCoolingCooling
Samsung 840 Pro 120GB EK Supremacy (CPU) NF F12's P/P (360 Rad)  NF A14's (420 Rad)  
CoolingCoolingCoolingCooling
XSPC Chrome Compression Fittings EK RES X3 150 Primochill PremoFlex Advanced LRT Clear 1/2 ID EK-FC (R9 290X) 
CoolingCoolingCoolingOS
EK D5 Vario Top-X  Phobya G-Changer V2 360mm Phobya G-Changer V2 420mm Win 10 x64 Pro 
MonitorKeyboardPowerCase
BenQ XR3501 35" Curved Corsair Vengeance K90 Seasonic X-1250 Gold (v2) Corsair 900D 
MouseAudio
Logitech G400s Senn HD 598 
  hide details  
Reply
X79-GCN
(22 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz HT GIGABYTE GA-X79-UP4 AMD R9-290X GEil Evo Potenza DDR3 2400MHz CL10 (4x4GB) 
Hard DriveCoolingCoolingCooling
Samsung 840 Pro 120GB EK Supremacy (CPU) NF F12's P/P (360 Rad)  NF A14's (420 Rad)  
CoolingCoolingCoolingCooling
XSPC Chrome Compression Fittings EK RES X3 150 Primochill PremoFlex Advanced LRT Clear 1/2 ID EK-FC (R9 290X) 
CoolingCoolingCoolingOS
EK D5 Vario Top-X  Phobya G-Changer V2 360mm Phobya G-Changer V2 420mm Win 10 x64 Pro 
MonitorKeyboardPowerCase
BenQ XR3501 35" Curved Corsair Vengeance K90 Seasonic X-1250 Gold (v2) Corsair 900D 
MouseAudio
Logitech G400s Senn HD 598 
  hide details  
Reply
post #6 of 7
Quote:
Originally Posted by BradleyW View Post


Thanks guy's.

The preferred way to output characters that aren't part of the non-extended ASCII set is with Unicode escape sequences.
Code:
#include <iostream.h>

using namespace std;

int main() {
  float price = 5.00;
  cout << "The price is \u00A3" << fixed << setprecision(2) << price << endl;

  return 0;
}

In this example, "\u00A3" is a unicode escape sequence that represents the GBP sign. You can see information about this character at http://www.fileformat.info/info/unicode/char/a3/index.htm (the site even gives you the C++ escape sequence to use).
Cube
(9 items)
 
  
CPUMotherboardRAMHard Drive
i7-4930k EVGA X79 Dark Corsair Vengeance Pro Samsung 840 Pro 
CoolingMonitorPowerCase
Corsair H100i Viewsonic VP2770 EVGA SuperNova 1000P2 Corsair Air 540 
Mouse
Corsair M65 
  hide details  
Reply
Cube
(9 items)
 
  
CPUMotherboardRAMHard Drive
i7-4930k EVGA X79 Dark Corsair Vengeance Pro Samsung 840 Pro 
CoolingMonitorPowerCase
Corsair H100i Viewsonic VP2770 EVGA SuperNova 1000P2 Corsair Air 540 
Mouse
Corsair M65 
  hide details  
Reply
post #7 of 7
Thread Starter 
Quote:
Originally Posted by jvolkman View Post

The preferred way to output characters that aren't part of the non-extended ASCII set is with Unicode escape sequences.
Code:
#include <iostream.h>

using namespace std;

int main() {
  float price = 5.00;
  cout << "The price is \u00A3" << fixed << setprecision(2) << price << endl;

  return 0;
}

In this example, "\u00A3" is a unicode escape sequence that represents the GBP sign. You can see information about this character at http://www.fileformat.info/info/unicode/char/a3/index.htm (the site even gives you the C++ escape sequence to use).

Thank you for this.
X79-GCN
(22 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz HT GIGABYTE GA-X79-UP4 AMD R9-290X GEil Evo Potenza DDR3 2400MHz CL10 (4x4GB) 
Hard DriveCoolingCoolingCooling
Samsung 840 Pro 120GB EK Supremacy (CPU) NF F12's P/P (360 Rad)  NF A14's (420 Rad)  
CoolingCoolingCoolingCooling
XSPC Chrome Compression Fittings EK RES X3 150 Primochill PremoFlex Advanced LRT Clear 1/2 ID EK-FC (R9 290X) 
CoolingCoolingCoolingOS
EK D5 Vario Top-X  Phobya G-Changer V2 360mm Phobya G-Changer V2 420mm Win 10 x64 Pro 
MonitorKeyboardPowerCase
BenQ XR3501 35" Curved Corsair Vengeance K90 Seasonic X-1250 Gold (v2) Corsair 900D 
MouseAudio
Logitech G400s Senn HD 598 
  hide details  
Reply
X79-GCN
(22 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz HT GIGABYTE GA-X79-UP4 AMD R9-290X GEil Evo Potenza DDR3 2400MHz CL10 (4x4GB) 
Hard DriveCoolingCoolingCooling
Samsung 840 Pro 120GB EK Supremacy (CPU) NF F12's P/P (360 Rad)  NF A14's (420 Rad)  
CoolingCoolingCoolingCooling
XSPC Chrome Compression Fittings EK RES X3 150 Primochill PremoFlex Advanced LRT Clear 1/2 ID EK-FC (R9 290X) 
CoolingCoolingCoolingOS
EK D5 Vario Top-X  Phobya G-Changer V2 360mm Phobya G-Changer V2 420mm Win 10 x64 Pro 
MonitorKeyboardPowerCase
BenQ XR3501 35" Curved Corsair Vengeance K90 Seasonic X-1250 Gold (v2) Corsair 900D 
MouseAudio
Logitech G400s Senn HD 598 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › How to use a '£' Sign in C++?