Why do I need to write std::ios::sync_with_stdio inside main?

If I write :

    #include <iostream>

    using namespace std;


        main(){

            ios::sync_with_stdio(false);

cout << "hi";
}

Then, the program compiles correctly, but if I write:

#include <iostream>

    using namespace std;

    ios::sync_with_stdio(false);

        main(){
    cout << "hi";
            }

then GCC produces the following error:

error: specializing member ‘std::basic_ios::sync_with_stdio’ requires ‘template<>’ syntax
ios::sync_with_stdio(false);

What does this error mean, and how to correct it (if possible)?


Source: gcc

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.