how to output degree symbol in C programs with iso_8859-1?

你离开我真会死。 提交于 2019-12-05 21:55:30

To use other characters than ASCII, on most platforms you have to switch to a "locale" that is able to handle such characters. At the beginning of your main you should have

   #include <locale.h>
   int main(void) {
     setlocale(LC_ALL, "");
   ...
   }

here the empty string "" literally stands for the default locale of your platform.

Now, what locale is supported by your platform is something that you'd have to find out yourself, you didn't give us enough information. I'd strongly suggest not to go with an obsolete one as you were proposing but to go for UTF-8.

Usually you may embed UTF-8 character sequences naturally in normal C strings, so something like "105° C" should print out as the degree character.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!