简体   繁体   English

对于我的C作业,我不了解使用重定向来测试程序意味着什么?

[英]For my C assignment, I am don't understand what it means by using redirection to test the program?

I don't understand what my assignment means about redirection. 我不了解我的作业对重定向的含义。 My assignment says: 我的作业说:

Use input redirection to test your program. 使用输入重定向来测试您的程序。 Note that your program reads from the user using scanf and input redirection feeds the file contents to your program. 请注意,您的程序使用scanf从用户读取,并且输入重定向将文件内容馈送到您的程序。 You don't have to use any file operations in your program. 您不必在程序中使用任何文件操作。 Consider the following file a.txt: 考虑以下文件a.txt:

 4 10 20 15 5 -1 

Does this mean that I have to make a a.text file? 这是否意味着我必须制作一个a.text文件? where does the a.txt file with the numbers even come from??? 带有数字的a.txt文件从何而来???

The instructor is telling you to create a text file with a series of numbers in it to feed to your program. 讲师告诉您创建一个文本文件,其中包含一系列数字以馈入程序。 Input redirection means using < at the shell when running your program to make it use the given file as stdin. 输入重定向意味着在运行程序时在外壳程序上使用< ,以使其使用给定文件作为stdin。

For example: 例如:

./myprogram < a.txt

The file a.txt is treated as the program's stdin. 文件a.txt被视为程序的标准输入。

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

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