Пространства имён
Варианты
Действия

std::ios_base::sync_with_stdio

Материал из cppreference.com
< cpp‎ | io‎ | ios base

 
 
Библиотека ввода/вывода
Манипуляторы ввода/вывода
Функции print (C++23)
Ввод/вывод в стиле C
Буферы
(устарело в C++98)
Потоки
Абстракции
Файловый ввод/вывод
Ввод/вывод строк
Ввод/вывод массивов
(устарело в C++98)
(устарело в C++98)
(устарело в C++98)
Синхронизированный вывод
Типы
Интерфейс категорий ошибок
(C++11)
 
std::ios_base
Функции-члены
Форматирование
Оригинал:
Formatting
Текст был переведён автоматически используя Переводчик Google.
Вы можете проверить и исправить перевод. Для инструкций щёлкните сюда.
Языки
Оригинал:
Locales
Текст был переведён автоматически используя Переводчик Google.
Вы можете проверить и исправить перевод. Для инструкций щёлкните сюда.
Внутренние расширяемый массив
Оригинал:
Internal extensible array
Текст был переведён автоматически используя Переводчик Google.
Вы можете проверить и исправить перевод. Для инструкций щёлкните сюда.
Разное
Оригинал:
Miscellaneous
Текст был переведён автоматически используя Переводчик Google.
Вы можете проверить и исправить перевод. Для инструкций щёлкните сюда.
ios_base::sync_with_stdio
Член классов
Оригинал:
Member classes
Текст был переведён автоматически используя Переводчик Google.
Вы можете проверить и исправить перевод. Для инструкций щёлкните сюда.
Член типов
Оригинал:
Member types
Текст был переведён автоматически используя Переводчик Google.
Вы можете проверить и исправить перевод. Для инструкций щёлкните сюда.
 
static bool sync_with_stdio( bool sync = true );

Sets whether the standard std::cin, std::cout, std::cerr, std::clog, std::wcin, std::wcout, std::wcerr and std::wclog C++ streams are synchronized to the standard stdin, stdout, stderr and stdlog C streams after each input/output operation.

For a standard stream str, synchronized with the C stream f, the following pairs of functions have identical effect:

1) std::fputc(f, c) and str.rdbuf()->sputc(c)
2) std::fgetc(f) and str.rdbuf()->sbumpc(c)
3) std::ungetc(c, f) and str.rdbuf()->sputbackc(c) In practice, this means that the C++ and the C streams use the same buffer, and therefore, can be mixed freely. In addition, synchronized C++ streams are guaranteed to be thread-safe (individual characters output from multiple threads may interleave, but no data races occur)

If the synchronization is turned off, the C++ standard streams are allowed to buffer their I/O independently, which may be considerably faster in some cases.

By default, all eight standard C++ streams are synchronized with their respective C streams.

It is implementation-defined if this function has any effect if called after some I/O occurred on the standard stream.

Содержание

[править] Параметры

sync the new synchronization setting

[править] Возвращаемое значение

synchronization state before the call to the function

[править] Пример

#include <iostream>
#include <cstdio>
int main()
{
    std::cout.sync_with_stdio(false);
    std::cout << "a\n";
    std::printf("b\n");
    std::cout << "c\n";
}

Вывод:

b
a
c

[править] См. также

пишет в стандартный выходной поток C stdout
(глобальный объект) [править]
пишет в стандартный поток ошибок C stderr, небуферизирована
(глобальный объект) [править]
пишет в стандартный поток ошибок C stderr
(глобальный объект) [править]