我读了<代码>fre open,将所有<代码>>印本>f转至档案中,但我希望该产出也将在屏幕上印刷。 是否很容易将印刷材料转至档案并获得细微线产出?
感谢!
我读了<代码>fre open,将所有<代码>>印本>f转至档案中,但我希望该产出也将在屏幕上印刷。 是否很容易将印刷材料转至档案并获得细微线产出?
感谢!
从方案之外使用“tee”:
# echo foo | tee foo.txt
foo
# cat foo.txt
foo
事实上,你可以打开一个渠道,通过这个渠道来书写档案,而这个渠道是系统税。 为此:
FILE *stream_to_write_to = popen( "tee filename.txt" );
fprintf( stream_to_write_to, "goes to filename.txt and stdout
" );
我很想知道,从C到C到处是否迅速这样做,因为在某种程度上,这涉及复制数据。 很容易获得两卷手,以写到同一地方,使用 d( d)或类似的手套,但反之则更为trick。 这可能涉及将一个单元(常见的例子是“斜体”推向下游),尽管我确实从未看到过这种使用,因此我亲爱看到一部工作法典。
我可以提供的最佳参考是史蒂文斯的“联合国IX环境中的先进方案”。
最新情况:
谈到下文R节的评论,上述解决办法略微增加了一个简便的墨卡/ex,并重新引导儿童处理某些地方的问题。 两者都将解决这个问题,尽管我更喜欢上述问题,因为它更容易清理,但坦率地说,这两种解决办法都很重。 因为k()没有轻重功能。 如果问题的精神是没有 for/ex,那么我不敢肯定,我也很想知道。 如果 for/ex是oka,则直接使用或使用open( p)会 ha。
另一种选择是写上像<条码>f条码>这样的功能,但将产出引向两个不同地点。 例如:
#include <stdio.h>
#include <stdarg.h>
void printf2(FILE *fp, char *format, ...)
{
va_list ap;
va_list ap2;
va_start(ap, format);
va_copy(ap2, ap);
vfprintf(fp, format, ap);
va_end(ap);
vprintf(format, ap2);
va_end(ap2);
}
然后,请打电话<条码>。 http://www.un.org/Depts/DGACM/index_chinese.htm
FILE *fp = fopen("/tmp/foo", "w");
printf2(fp, "This is a test.
");
这种做法不使用分处理法或管道,必要时可将分处理法扩大到多个档案点。
<代码>fre open不是重排方向的良好想法。 它不一定重复使用同一档案编号,因此儿童过程可能不会继承新的排位(或最终完全没有排位)。 最好使用<代码>开放<>/代码>,然后使用<代码>dup2或<编码>close(0),然后使用<代码>开放<>>/>,以设定新的淘汰目标。
For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...
最好、最小、最快、开放的来源、C/C++ 3d 提供方(在3ds max模型的支持下),而不是通用公平市价,
Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...
I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...
I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...
I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...
Is there anything other than DDD that will draw diagrams of my data structures like DDD does that runs on Linux? ddd is okay and runs, just kind of has an old klunky feeling to it, just wanted to ...
Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...