[英]Add smiley face in c
I am trying to print smiley face using C. My program is我正在尝试使用 C 打印笑脸。我的程序是
#include <stdio.h>
int main()
{
int x;
char i=1;
for(x=1;x<=800;x++)
{
printf(" %c ", i);
if(x==800)
printf("\n");
if(x==800)
break;
}
}
I am using Ubuntu Terminal.我正在使用 Ubuntu 终端。 It is working fine in
Windows
but not in Ubuntu
.它在
Windows
运行良好,但在Ubuntu
。 Please help.请帮忙。 Thanks in advance
提前致谢
If you want to output a smiley face you cannot use the ascii characters.如果要输出笑脸,则不能使用 ascii 字符。 Again, look at that ascii man page for the complete set of available characters.
再次查看 ascii 手册页以获取完整的可用字符集。
However you can use the UTF-8 encoding, if your terminal support it.但是,如果您的终端支持,您可以使用UTF-8编码。 The code snippet below print a smiley face with sunglasses on my terminal:
下面的代码片段在我的终端上打印了一个带太阳镜的笑脸:
#include <stdio.h>
int main()
{
char s[] = { 0xf0, 0x9f, 0x98, 0x8e, 0};
printf("%s\n", s);
}
Another possibility is to use另一种可能性是使用
printf("\u263A\n");
According to his UTF-8 page which report the C/C++/Java
source code根据他报告
C/C++/Java
源代码的UTF-8页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.