Operating System - HP-UX
1748246 Members
3542 Online
108760 Solutions
New Discussion юеВ

how to generate "cent" sign in c code

 
SOLVED
Go to solution
Renda Skandier
Frequent Advisor

how to generate "cent" sign in c code

hi,
I'm trying to write an application that prints
$1.19 if the amount is greater than 99 cents but print .99 "cents sysmbol" if less than a dollar.
The dollar sign work fine but I can not make the "cents".
I know that the octal equiv is 0242 but can not get it to print to my screen
thanks
7 REPLIES 7
Michael Steele_2
Honored Contributor

Re: how to generate "cent" sign in c code

Refer to your ASCII table and the ASCII value for cent and the printf command.
Support Fatherhood - Stop Family Law
Graham Cameron_1
Honored Contributor

Re: how to generate "cent" sign in c code

The ascii table stops at octal 177 (dec 127) whereas the code for the symbol you want is beyond this.

Nevertheless, on my system I can get a cent symbol with printf ("%c\n", 162).
(octal 242 == decimal 162).

You can test this without writing a C program:

echo |awk '{printf "%c\n", 162}'

If that doesn't work for you then I think it's a problem with your terminal or emulator, not with C.

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Renda Skandier
Frequent Advisor

Re: how to generate "cent" sign in c code

well the octal 242 or hex 82 is what i was looking for but that doesn't work for me.
I'm trying to send a printf to a Monarch label printer and although I don't get an error, I'm still printing a blank space, no "cent sign".

Any other suggestions?
thanks
Graham Cameron_1
Honored Contributor

Re: how to generate "cent" sign in c code

Renda

You need to speak to Monarch or check the manual.
I've used these things in the past and given the correct escape sequences they will usually print most things.

Good luck.

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Bruno Ganino
Honored Contributor

Re: how to generate "cent" sign in c code

Renda, i think that you must modify the file of terminfo appropriate.

/usr/share/lib/terminfo/?/*

terminfo is a database produced that describes the capabilities of devices such as terminals and printers.
Devices are described in terminfo source files by specifying a set of capabilities, by quantifying certain aspects of the device, and by specifying character sequences that effect particular results.

HTH
Bruno
Torino (Turin) +2H
Antoniov.
Honored Contributor
Solution

Re: how to generate "cent" sign in c code

Such as Euro sign and Pound Sign, cent sign is not standard ANSI, so you MUST choice codeset and setup it on ALL video and ALL printers.
The majoir problem is difference between video VT and printer to PC.
VT can use ISO_LATIN1 and you cna find cent at 242 (hex 162). But printer, usually, use PC437 or PC850; so to print you have send code 155 (hex 9B). If you send 155 (hex 9B to VT you send a control code CSI that is same as esc [ (escape followed opened square).
So, you cannot viwe and print the cent sign.
This problem is known by European people.

Bye
Antoniov
Antonio Maria Vigliotti
Renda Skandier
Frequent Advisor

Re: how to generate "cent" sign in c code

I changed 82 Hex to 9B Hex and my code worked great.
Thanks so much!