我正在使用 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/