小编Rav*_*dav的帖子

无法在ubuntu的输出中获得退格符(\ b)(K&R示例)

#include <stdio.h>
/* replacing tabs and backspaces with visible characters */
int main()
{
  int c;
  while ( (c = getchar() ) != EOF) {
       if ( c == '\t')
          printf("\\t");
       else if ( c == '\b')
          printf("\\b");
       else if ( c == '\\')
          printf("\\\\");
       else 
          putchar(c);
    }

   return 0;
  }
Run Code Online (Sandbox Code Playgroud)

现在我的问题是..为什么我不能在输出中看到"\ b"?我已经在Ubuntu终端中编写了这段代码.有什么其他方法可以在输出中获得"\ b"字符​​吗?如果有,请用简单的词语解释,因为我刚开始学习C编程.这个例子来自K&R练习1-10.

c ubuntu kernighan-and-ritchie

2
推荐指数
1
解决办法
1186
查看次数

什么是ubuntu中的EOF以及关于Kernighan和Ritchie的EOF

我已经开始学习C了,我也开始使用Ubuntu.我正在通过终端在vim中编写代码.我一直在学习Kernighan和Ritchie.这是代码 -

#include <stdio.h>

int main()
{
 int c;
 while ( (c = getchar()) != EOF)
 putchar(c);
 return 0;
 }
Run Code Online (Sandbox Code Playgroud)

现在,我的问题是: -

  1. 程序停止,如果我按ctrl + z,但它也终止,如果我按ctrl + D,当我在线阅读它说ctrl + z是Windows中的EOF和Linux中的ctrl + d.这是否意味着它们都是Linux中的EOF?如果是这样,那么其他EOF是什么?
  2. 在本书的第一章中有这么复杂的问题是否可以?或者我应该只是通读它,这些想法会在我阅读时被清除掉?

c ubuntu kernighan-and-ritchie

1
推荐指数
1
解决办法
6092
查看次数

标签 统计

c ×2

kernighan-and-ritchie ×2

ubuntu ×2