使用重定向操作℃之后检索标准输入; [英] Retrieving stdin after using the redirection operator <

查看:128
本文介绍了使用重定向操作℃之后检索标准输入;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个编程任务,我们有以下要求:

For a programming assignment, we have the following requirements:


  1. 它需要用C语言编写一个命令行程序。

  2. 它需要读取一个文本文件的文本。但是,我们通过使用Unix的重定向操作符&LT做到这一点;在运行程序时,而不是具有程序加载该文件本身。 (所以程序读取由pretending它从标准输入读取文本。)

  3. 从文件中读取数据后,该程序是轮询用户做它的工作之前,一些额外的信息。

经过反复研究,我无法找到一个方法来检索老标准输入以实现部分(3)。是否有人知道如何或者如果这是甚至可能吗?

After much research, I can't find a way to retrieve the "old" stdin in order to accomplish part (3). Does anybody know how or if this is even possible?

从技术上部(3)是奖金部分,其中教师大概没有实现自己(这是非常冗长)的一部分,所以这是可能的,这是不可能的,这是对他的疏忽。不过,我当然不希望跳转到这一结论。

Technically part (3) is part of a bonus section, which the instructor probably didn't implement himself (it's very lengthy), so it's possible that this is not possible and it's an oversight on his part. However, I certainly don't want to jump to this conclusion.

推荐答案

在Linux中,我会打开控制终端的/ dev / tty的。

On linux, i would open the controlling terminal /dev/tty.

这篇关于使用重定向操作℃之后检索标准输入;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆