问题标签 [fflush]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
subprocess - 如何强制子进程刷新标准输出缓冲区?
平台:windows 8.1 IDE:vs2013 使用c/c++
进程使用管道重定向读取子进程的标准输出。
但是子进程在 printf 之后不调用 fflush,因此进程 A 在子进程运行到结束之前无法从管道中读取任何内容。
ps:我有子进程的源代码,但是很难修改它们。
那么进程A是否可以强制子进程刷新标准输出缓冲区在子进程运行结束之前读取一些东西呢?(与 fflush 一样有效)
fork - 使用 xinetd/inetd,为什么服务器要调用 fflush()?
xinetd 上的所有程序(我读过)都调用 fflush()。为什么?
例如,Inetd-维基百科
c - 检查输入是否为整数
我需要创建一个从用户那里获取输入的函数,并确保它是一个整数并且不包含任何字符。
我编写了这段代码,它非常适用于整数和单个字符。但如果我输入dfd
即多字符输入,它就会终止。下面是我在 Linux 上用 gcc 编译的代码:
c - fflush 函数可以增加 linux 中的文件描述符数量吗?
我的应用程序退出,因为它占用了太多文件描述符。所以我使用 gdb 来调试我的程序。当我使用 fflush 函数时,我发现文件描述符数量增加了。
例如:
进程 ID 为 13593。变量 pFile 指向文件 send.dat 。
谁能告诉我原因?非常感谢。
c - c中gets()之前的fflush(stdin)
好的,我正在解决代码厨师中的一个问题(非常容易)。它简要说明:
- 将给出一个字符串形式的问题,并且必须生成另一个字符串,该字符串在问题字符串中没有使用任何字母。假设大写和小写相同。
- 如果所有字母都已使用,只需打印 ~ 符号。
我的整个逻辑都是正确的,除了我在输入中发现错误,这是由于在 gets() 之前使用 fflush(stdin) 引起的。请解释为什么这是一个错误?忽略其余代码。
问题链接:http: //www.codechef.com/problems/NOLOGIC/
链接到错误的解决方案:http: //www.codechef.com/viewsolution/3881817
链接到更正的解决方案:http: //www.codechef.com/viewsolution/3881827
请注意:在更正的代码中,我仅在不使用 fflush(stdin) 和使用 getchar() 方面进行了更改
c++ - fflush 到底是什么,它有什么作用?
我正在阅读http://www.cplusplus.com/reference/cstdio/fflush/,我很好奇它的含义。根据该网站,它说:
如果给定的流是为写入而打开的(或者如果它是为更新而打开的并且最后的 i/o 操作是一个输出操作)其输出缓冲区中的任何未写入的数据都将写入文件。
输出缓冲区到文件是什么意思?
c - 为什么 fflush(stdin) 在 while 循环中执行两次 scanf() 输入检查?
初学者程序员在这里学习C
我的部分代码要求用户输入数字,并将进入 while 循环以检查输入的值是否为数字,如果不是,则 while 循环将清除输入(以停止无限循环),并要求输入数字再次。
问题是,当我清除输入然后在 while 循环中再次请求 scanf() 时,它显然清除了两次,我必须再次输入数字才能获得结果。
这是有问题的代码的一部分:
如果有人可以解释为什么会这样,请解释或给我一些关于如何继续的提示。
太感谢了!
c# - Clear the current line, as with fflush(stdout) in C
I have a very long for loop, which prints out many lines of information. I would like to keep it to just one line that overwrites previous lines. I tried Console.out.flush() but it does not seem to work.
c - Using many calls to fprintf; when should I use fflush?
I have a simple little program that converts one filetype to another. There are quite a few calls to fprintf() (roughly linearly dependent to the size of the file to convert). When I started, there were no calls to fflush(). On small files (<10 Kb) there was no problem whatsoever. On a larger file, (>40 Kb) the whole thing crashed when the call to fclose() was reached.
So, I thought maybe I was letting the buffer fill up too much or something, so I put in calls to fflush() after roughly* 512 calls to fprintf (where each call prints out between 8 and 10 characters). The program still crashes on the call to fclose().
*Because I'm not actually counting the calls to fprintf and I'm using another count that's already in the program, it is possible for this number to be less than 512.
This brings me to my question. When should fflush() be called? Should it be called after a certain amount of data has been fprintf'd? Or is there something I'm missing?
Thanks
By the way, in case it's pertinent, I'm on Windows 7 (64bit) and I've fopen'd the output file in "a+" mode
c++ - 可以在刷新操作中写入文件失败
我一次将内容写入 csv 文件,想知道在刷新操作过程中写入是否会失败
我的目的是了解写入文件可能被破坏的不同方式
假设以下是 csv 文件写入成功后的结构
假设将第 3 行刷新到文件时发生错误,是否会导致以下形式
或者
或者
或者
如果需要,我的代码
东西.cpp