如何在 C 中打印斜杠(/或 \)? [英] How to print out a slash (/ or \) in C?
本文介绍了如何在 C 中打印斜杠(/或 \)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这是一个非常愚蠢和简单的问题,但我一直在尝试打印出应该输出此内容的机器人图像:
I know this is a very silly and simple question but I've been trying to print out an image of a robot that should output this:
+----------+
| |
| /\ /\ |
| \/ \/ |
| |
| [-=-=-] |
+----------+
我被卡住的部分是打印眼睛.最初我编码:
The part I'm stuck on is printing out the eyes. originally I coded:
printf("| /\ /\ |");
printf("| \/ \/ |");
但是显示了一个错误,所以我记得你需要双斜线所以:
but an error showed, so I remembered that you need to double slash so:
printf("| \/\\ \/\\ |");
printf("| \\\/ \\\/ |");
但是即使在那之后仍然显示函数 printf 的隐式声明的错误?!我不明白这个错误.有人可以解释一下如何解决这个问题吗?
but an error saying implicit declaration of function printf is showing even after that?! I don't understand the error. Can someone explain how to fix this please?
推荐答案
您不需要转义正斜杠.
这对我有用:
#include <stdio.h>
int main()
{
printf("| /\\ /\\ |");
printf("| \\/ \\/ |");
return 0;
}
这篇关于如何在 C 中打印斜杠(/或 \)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文