I have a problem with stdout and stdin .when i store data by using stdout i cant getback the same data using stdin . so please help me how can i solve my problem. Ram
我有stdout和stdin的问题。当我使用stdout存储数据时我无法使用stdin获取相同的数据。所以请帮助我如何解决我的问题。内存
1 个解决方案
#1
Data you write to stdout will not be automatically available to stdin. Data written to the stdout stream is available to be read by whatever process is connected to that stream. Normally that is the terminal or console where the program was started. It can also be another process that was connected to the first one through a pipe or it can be a file when redirection was used.
您写入stdout的数据将不会自动提供给stdin。写入stdout流的数据可以通过连接到该流的任何进程读取。通常,这是程序启动的终端或控制台。它也可以是通过管道连接到第一个进程的另一个进程,或者在使用重定向时它可以是文件。
If you want to read the data your program wrote to stdout via stdin on a subsequent run you can use redirections like this
如果要在后续运行中读取程序通过stdin写入stdout的数据,可以使用这样的重定向
$ program > data.out
Will store anything that is written to stdout in the file data.out. Then,
将在文件data.out中存储写入stdout的任何内容。然后,
$ program < data.out
... will make the contents of data.out available to the program in stdin
...将使stdin中的data.out内容可供程序使用
Please post your code and some more detailed description of what you are trying to do if this isn't what you were trying to achieve.
如果这不是您想要实现的目标,请发布您的代码以及您正在尝试做的更详细的描述。
#1
Data you write to stdout will not be automatically available to stdin. Data written to the stdout stream is available to be read by whatever process is connected to that stream. Normally that is the terminal or console where the program was started. It can also be another process that was connected to the first one through a pipe or it can be a file when redirection was used.
您写入stdout的数据将不会自动提供给stdin。写入stdout流的数据可以通过连接到该流的任何进程读取。通常,这是程序启动的终端或控制台。它也可以是通过管道连接到第一个进程的另一个进程,或者在使用重定向时它可以是文件。
If you want to read the data your program wrote to stdout via stdin on a subsequent run you can use redirections like this
如果要在后续运行中读取程序通过stdin写入stdout的数据,可以使用这样的重定向
$ program > data.out
Will store anything that is written to stdout in the file data.out. Then,
将在文件data.out中存储写入stdout的任何内容。然后,
$ program < data.out
... will make the contents of data.out available to the program in stdin
...将使stdin中的data.out内容可供程序使用
Please post your code and some more detailed description of what you are trying to do if this isn't what you were trying to achieve.
如果这不是您想要实现的目标,请发布您的代码以及您正在尝试做的更详细的描述。