가능한 중복 :
Why does printf not flush after the call unless a newline is in the format string? (in C)"의 printf"문자열을 인쇄하지 않습니다 immediatly
나는했습니다과 같은 코드 :
printf("Starting nets allocation...");
while(...)
{
...some operations...
}
puts("DONE");
코드는해야 인쇄 immediatly 문자열 "Starting nets allocation ..."을 입력 한 다음 루프가 끝나면 "DONE"이 인쇄됩니다.
대신 프로그램이 먼저 루프를 수행 한 다음 "Starting net sets ... DONE"문자열을 인쇄합니다. 왜 이런 일이 발생합니까? 이 문제를 어떻게 해결할 수 있습니까? fflush
를 사용하여 - - 당신이 즉시 출력을 원하는 경우는 출력 스트림을 플러시해야합니다 있도록
[질문 및 대답 방법] (http://stackoverflow.com/faq#howtoask). – bitmask