209 questions
709
votes
10
answers
542k
views
Why does printf not flush after the call unless a newline is in the format string?
Why does printf not flush after the call unless a newline is in the format string? Is this POSIX behavior? How might I have printf immediately flush every time?
123
votes
20
answers
543k
views
How can I clear an input buffer in C?
I have the following program:
int main(int argc, char *argv[])
{
char ch1, ch2;
printf("Input the first character:"); // Line 1
scanf("%c", &ch1);
printf("...
81
votes
21
answers
167k
views
How to flush output after each `echo` call?
I have a php script that only produces logs to the client.
When I echo something, I want it to be transferred to client on-the-fly.
(Because while the script is processing, the page is blank)
I had ...
190
votes
4
answers
86k
views
NHibernate ISession Flush: Where and when to use it, and why?
One of the things that get me thoroughly confused is the use of session.Flush,in conjunction with session.Commit, and session.Close.
Sometimes session.Close works, e.g., it commits all the changes ...
66
votes
2
answers
78k
views
c++ force std::cout flush (print to screen)
I have code such as the following:
std::cout << "Beginning computations..."; // output 1
computations();
std::cout << " done!\n"; // output 2
The problem, however, is ...
36
votes
5
answers
30k
views
endl and flushing the buffer
In the C++ primer book, in chapter (1), it mentions the following:
endl is a special value, called a manipulator, that when written to an
output stream has the effect of writing a newline to the ...
24
votes
7
answers
21k
views
How to ensure all data has been physically written to disk?
I understand that .NET FileStream's Flush method only writes the current buffer to disk, but dependent on Windows' disk driver and the hard disk firmware this is no guarantee that the data is actually ...
18
votes
14
answers
52k
views
php flush not working
<?php
for($i=0;$i<20;$i++)
{
echo 'printing...<br />';
ob_flush();
flush();
usleep(300000);
}
?>
Url that contains the code: http://domainsoutlook.com/sandbox/delayed....
104
votes
5
answers
266k
views
MySQL: When is Flush Privileges in MySQL really needed?
When creating new tables and a user to go along with it, I usually just invoke the following commands:
CREATE DATABASE mydb;
GRANT ALL PRIVILEGES ON mydb.* TO myuser@localhost IDENTIFIED BY "...
17
votes
3
answers
8k
views
Does new line character also flush the buffer?
I understand that questions like, difference between endl and \n have been answered many times on SO. But they only mention that endl is able to flush the buffer onto the stdout, while \n, does not.
...
32
votes
9
answers
46k
views
flush in java.io.FileWriter
I have a question in my mind that, while writing into the file, before closing is done, should we include flush()??. If so what it will do exactly? dont streams auto flush??
EDIT:
So flush what it ...
22
votes
4
answers
28k
views
PHP - Flushing While Loop Data with Ajax
Using PHP, I would like to make a while loop that reads a large file and sends the current line number when requested. Using Ajax, I'd like to get the current line count and print it out onto a page. ...
4
votes
4
answers
4k
views
Is this the proper way to flush the C input stream?
Well I been doing a lot of searching on google and on here about how to flush the input stream properly. All I hear is mixed arguments about how fflush() is undefined for the input stream, and some ...
27
votes
4
answers
19k
views
How can I output data before I end the response?
Here is my snippet I tested it in Chrome 11, and Firefox 4:
var http = require('http');
http.createServer(function(request, response){
// Write Headers
response.writeHead(200);
// Write ...
18
votes
2
answers
13k
views
C++ cout and cin buffers, and buffers in general
Can someone explain the concept of buffers a bit more explicitly? I understand that buffers are data structures where characters are stored, and the place where the data is to be read from. What is ...
8
votes
7
answers
55k
views
No console output on cout
I have a problem with Eclipse IDE for C/C++ Developers.
I'm writting a smal tool for converting Strings. While testing on some point eclipse stopped to give console output.
e.g.:
cout<<"...
46
votes
3
answers
27k
views
Not buffered http.ResponseWritter in Golang
I'm writing a simple web app in Go and I want my responses to be streamed to the client (i.e. not buffered and sent in blocks once the request is fully processed) :
func handle(res http....
12
votes
3
answers
12k
views
python print function in real time
I recently switched OS and am using a newer Python (2.7). On my old system, I used to be able to print instantaneously. For instance, suppose I had a computationally intense for loop:
for i in range(...
12
votes
2
answers
23k
views
Python3 sleep() problem
I was writing a simple program on Python 3.1 and I stumbled upon this:
If I run this on the IDLE it works as intended - prints "Initializing." and then adds two dots, one after each second, and waits ...
6
votes
5
answers
20k
views
Flushing stdin after every input - which approach is not buggy?
After Mark Lakata pointed out that the garbage isn't properly defined in my question I came up with this. I'll keep this updated to avoid confusions.
I am trying to get a function that I can call ...
13
votes
5
answers
50k
views
How to flush the CPU cache in Linux from a C program?
I am writing a C program in which I need to flush my memory. I would like know if there is any UNIX system command to flush the CPU cache.
This is a requirement for my project which involves ...
3
votes
1
answer
2k
views
Flushing fopen()'ed files opened in update mode,between read and write operations.Explicit flushing needed?
I have read this about the switch between read and write operations(and vice-versa) for files opened for update using fopen() (LINK)
"For files open for update (those which include a "+" sign), on ...
1
vote
3
answers
6k
views
Why fprintf doesn't write directly into the file unless fflush() is used?
I have written a daemon that writes a value in a file. What I have observed is that when I keep writing on a file, there is nothing visible in the file. in other hand, If I use fflush() method then ...
53
votes
2
answers
18k
views
Do you need to call Flush() on a stream or writer if you are using the “using” statement?
I am not sure whether I need to call Flush() on the used objects if I write something like this:
using (FileStream...)
using (CryptoStream...)
using (BinaryWriter...)
{
// do something
}
Are they ...
24
votes
3
answers
84k
views
Clearing the serial port's buffer
This is what my function looks like to open the serial port (using Ubuntu 12.04):
int open_port(void)
{
int fd; /* File descriptor for the port */
fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | ...