c - 字符串 "Putty"的奇怪出现

标签 c putty

我正在使用 putty 运行一个 C 程序(不要问为什么)并且它工作正常,除了当我运行一个特定的函数时,字符串“PuTTy”出现在末尾。这似乎并没有太大影响,但我很好奇是否有人知道为什么会发生这种情况以及这可能表明哪种错误。

注意:当我在 Linux 终端中运行代码时,没有任何错误。

最佳答案

这是 PuTTY 的一个问题,由您的程序发出 Control-E 字符引起。来自PuTTY FAQ :

A.7.12 When I cat a binary file, I get ‘PuTTYPuTTYPuTTY’ on my command line.

Don't do that, then.

This is designed behaviour; when PuTTY receives the character Control-E from the remote server, it interprets it as a request to identify itself, and so it sends back the string ‘PuTTY’ as if that string had been entered at the keyboard. Control-E should only be sent by programs that are prepared to deal with the response. Writing a binary file to your terminal is likely to output many Control-E characters, and cause this behaviour. Don't do it. It's a bad plan.

To mitigate the effects, you could configure the answerback string to be empty (see section 4.3.7); but writing binary files to your terminal is likely to cause various other unpleasant behaviour, so this is only a small remedy.

您的函数是否输出二进制字符,例如 Control-E?

关于c - 字符串 "Putty"的奇怪出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12039266/

相关文章:

c - 另一个字符移位 C

c++ - 关于 COM/ActiveX 对象的问题

c - 使用通配符 (*) 作为第一个输入时,程序出现段错误

mysql - 从服务器下载数据库sql文件

amazon-ec2 - 如何在 AWS 实例中设置 telnet?

c - 如何在 C 中编写 "thread safe"函数?

c - 我的 open() 命令没有创建新文件

bash - Putty/Bash alt + 左/右箭头键按单词移动光标

linux - 无法使用 key 文件

linux - 我如何连接到一个简单的 linux 控制台来执行一些任何人都可以使用 linux 操作系统的基本命令?