C language > Expert questions

Printing special characters

(1/1)

Doug Jones:
I'm using sanserif.
can someone tell me how to cause sprintf to print the degrees symbol?
I would like to place it after the third %d in the following code.

 sprintf (pictureInfo, "X %d Y %d  angle %d\n %d X %d pixels\n %s\n %3.3f X %3.3f inches\n",
                        picture[selection].posX,
                        picture[selection].posY,
                        picture[selection].angle,
                        picture[selection].dimsCx,
                        picture[selection].dimsCy,
                        path,
                        picture[selection].pSizeCx,
                        picture[selection].pSizeCy
                       );

 Thanks for the help, DJ

Doug Jones:
Never mind.
I found the hex value for it.
The code looks like this now -

 sprintf (pictureInfo, "X %d Y %d   %d%c\n %d X %d pixels\n %s\n %3.3f X %3.3f inches\n",
                        picture[selection].posX,
                        picture[selection].posY,
                        picture[selection].angle, 0xb0,
                        picture[selection].dimsCx,
                        picture[selection].dimsCy,
                        path,
                        picture[selection].pSizeCx,
                        picture[selection].pSizeCy
                       );

AlexN:

--- Quote from: Doug Jones on July 12, 2007, 01:42:00 AM --- sprintf (pictureInfo, "X %d Y %d   %d%c\n %d X %d pixels\n %s\n %3.3f X %3.3f inches\n",
                        picture[selection].posX,
                        picture[selection].posY,
                        picture[selection].angle, 0xb0,
                        picture[selection].dimsCx,
                        picture[selection].dimsCy,
                        path,
                        picture[selection].pSizeCx,
                        picture[selection].pSizeCy
                       );



--- End quote ---

or you write...

--- Code: --- sprintf (pictureInfo, "X %d Y %d   %d\xb0\n %d X %d pixels\n %s\n %3.3f X %3.3f inches\n",
                        picture[selection].posX,
                        picture[selection].posY,
                        picture[selection].angle,
                        picture[selection].dimsCx,
                        picture[selection].dimsCy,
                        path,
                        picture[selection].pSizeCx,
                        picture[selection].pSizeCy
                       );

--- End code ---

For a console application vou need \xf8 instead of \xb0.  ;)

Navigation

[0] Message Index

Go to full version