最近在看C Primer Plus,学到第八章中的重定向和文件部分时,遇到了一个困难,即将C程序的输入输出流由键盘和屏幕指向文件。书中提到的命令行在mac OS中并不适用,经过网上搜索,摸索出了方法,不过网上并没有完整的一套方法,现整理如下,如果能给跟我遇到一样问题的初学者带来帮助,我会很高兴。
原题为:
-
Suppose you have an executable program named count that counts thecharacters in its input. Devise a command-line command using the count program to count the number of characters in the file