{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# C++的转义字符" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 1. 转义字符" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "① 用于表示一些不能显示出来的ASCII字符。\n", "\n", "② 我们常用的转义字符有:\\n、\\\\、\\t。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#include \n", "using namespace std;\n", "\n", "int main()\n", "{\n", "\n", " //换行符 \\n\n", "\n", " cout << \"hello world\\n\";\n", "\n", " //反斜杠 \\\\ 要输出反斜杠\\时,要在前面加上一个反斜杠\n", "\n", " cout << \"\\\\\" << endl;\n", "\n", " //水平制表符\\t 可以整齐的输出数据\n", " cout << \"aaaa\\thellowworld\" << endl;\n", " cout << \"aa\\thellowworld\" << endl;\n", " cout << \"aaaaaa\\thellowworld\" << endl;\n", "\n", " system(\"pause\");\n", "\n", " return 0;\n", "\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "运行结果:\n", " - hello world\n", " - \\\n", " - aaaa hellowworld\n", " - aa hellowworld\n", " - aaaaaa hellowworld\n", " - 请按任意键继续. . ." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.6.3", "language": "python", "name": "python3.6.3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": false, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": true } }, "nbformat": 4, "nbformat_minor": 4 }