c - 第 1 天编程:C 中的 \n 问题
问题描述
这是关于一个超级小问题,但我似乎无法开始新的路线,因为我的书正在向我展示。(Perry 和 Miller 编写的 C 编程绝对初学者指南)我将在下面粘贴我的代码。
说的最后一个词应该在单独的行上,但由于某种原因, \n 那里不起作用。公平地说,这本书是基于 Code::Blocks 10.05 的,所以可能是格式问题?
// Absolute Beginner's Guide to C, 3rd Edition
// Chapter 4 Example 1--Chapter4ex3.c
#include <stdio.h>
main()
{
/* These three lines show you how to use the most popular Escape
Sequences */
printf("Column A\tColumn B\tColumn C");
printf("\nMy Computer\'s Beep Sounds Like This: \a!\n");
printf("\"Letz\bs fix that typo and then show the backslash ");
printf("character \\\" she said\n");
return 0;
}
解决方案
每当您需要换行时,您必须在此之前添加 \n 。因此,如果您想在新行中添加“说”,则在“说”之前添加 \n。像这样 printf("character \\\" she \nsaid");
推荐阅读
- java - 使用关系将 JPA obect 反序列化为 JSON
- javascript - 使用 Material UI 反应路由器
- c++ - 当我尝试在 C++ 中使用 lamda 表达式进行排序时出现问题
- swift - alamofire responseStreamString 解码
- r - dplyr 函数 mutate_at 抛出错误:期望一个单边公式、函数或函数名称
- swift - Swift:如何将 JSON 数据添加到我的结构中?
- java - Java HashMap为每个新值添加键+1?
- javascript - 如何在嵌套数组中定位对象属性并设置条件?
- python - 熊猫将行值旋转到数据框中的列
- spring - 使用gradle的spring boot多项目生成相同的jar