Pelles C forum

C language => Expert questions => Topic started by: Doug Jones on July 12, 2007, 12:10:47 am

Title: Printing special characters
Post by: Doug Jones on July 12, 2007, 12:10:47 am
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

Title: Re: Printing special characters
Post by: Doug Jones on July 12, 2007, 01:42:00 am
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
                       );

Title: Re: Printing special characters
Post by: AlexN on July 12, 2007, 07:37:04 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
                       );



or you write...
Code: [Select]
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
                       );

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