Optimizing Speed

Pages: 123
wtf wrote:
Does anyone know why I am unable to re-sync c++ streams with c stdio?


Well Microsoft says:

Microsoft wrote:
The static member function stores a stdio sync flag, which is initially true. When true, this flag ensures that operations on the same file are properly synchronized between the iostreams functions and those defined in the Standard C++ Library. Otherwise, synchronization may or may not be guaranteed, but performance may be improved. The function stores _Sync in the stdio sync flag and returns its previous stored value. You can call it reliably only before performing any operations on the standard streams.


I'd say that function is rather useless
I could still manually ensure the streams are synchronized by flushing the stream before calling printf though couldn't I?
1
2
3
4
5
6
7
8
int main()
{
    std::ios::sync_with_stdio(false);    
    cout << H << flush;
    printf("%s ", W);
    delete [] W;
    return 0;
}
Last edited on
wtf wrote:
I could still manually ensure the streams are synchronized by flushing the stream before calling printf though couldn't I?
Why mixing those two worlds. But flush should suffice.

Boost provides a better format handling than printf: http://www.boost.org/doc/libs/1_45_0/libs/format/index.html
Perhaps the only reason I can think of would be to avoid having to rewrite existing code.
Topic archived. No new replies allowed.
Pages: 123