简体   繁体   English

什么是标准输入输出?

[英]What is standard input and output?

I'm starting to work on a chess engine and I want to follow the uci interface where comunication is done using plane text.我开始在国际象棋引擎上工作,我想遵循使用平面文本进行通信的 uci 界面。 In the specification it says在规范中它说

all communication is done via standard input and output with text commands所有通信都是通过标准输入和输出与文本命令完成的

but I dont know what this means in real terms.但我不知道这实际上意味着什么。

I'm thinking of writing in C# as a .net standard library.我正在考虑用 C# 编写一个 .net 标准库。 I understand that as uci is cross platform we cannot talk in language like Console.WriteLine but what does that line in the api mean for me.我知道因为 uci 是跨平台的,所以我们不能用像Console.WriteLine这样的语言交谈,但是 api 中的那一行对我来说意味着什么。

Do I have to run a loop listening for Console.ReadLine() or something similar for standard input?我是否必须运行循环监听Console.ReadLine()或类似的标准输入? I just don't get it.我只是不明白。 Or should I be writing a console application that takes the input as a command line argument, and writes string to the console?或者我应该编写一个控制台应用程序,将输入作为命令行参数,并将字符串写入控制台?

The full specification can be downloaded from this link: http://download.shredderchess.com/div/uci.zip完整的规范可以从这个链接下载: http : //download.shredderchess.com/div/uci.zip

Any process have three default streams:任何进程都有三个默认流:

  • Standard input (stdin): This is the only input stream for all terminal or console aps.标准输入 (stdin):这是所有终端或控制台 aps 的唯一输入流。 When you cal Console.ReadLine or Console.Read the result is taken from this stream.当您调用 Console.ReadLine 或 Console.Read 时,结果是从此流中获取的。
  • Standard Output (stdout): When you call output-related commands in the console singleton class, all data goes here.标准输出 (stdout):当您在控制台单例类中调用与输出相关的命令时,所有数据都在此处。 For example the WriteLine or theWrite methods.例如 WriteLine 或 theWrite 方法。 The color and beeps commands send data to there too. color 和 beeps 命令也将数据发送到那里。
  • Standard error (stderr): This is a dedicated stream to print error-related content to the console.标准错误 (stderr):这是一个专用流,用于将与错误相关的内容打印到控制台。 This is dedicated because some applications and scripting solutions want to hide these messages.这是专用的,因为某些应用程序和脚本解决方案想要隐藏这些消息。

You can communicate with the containing process (such a console prompt) with these streams.您可以使用这些流与包含进程(例如控制台提示)进行通信。 The command line arguments can be passed only to the program's main method.命令行参数只能传递给程序的 main 方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM