首页 > 解决方案 > 第 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;

    } 

标签: ccodeblocks

解决方案


每当您需要换行时,您必须在此之前添加 \n 。因此,如果您想在新行中添加“说”,则在“说”之前添加 \n。像这样 printf("character \\\" she \nsaid");


推荐阅读