- The C Standard Library
- The C Standard Library
- The C++ Standard Library
- C++ Library - Home
- C++ Library - <fstream>
- C++ Library - <iomanip>
- C++ Library - <ios>
- C++ Library - <iosfwd>
- C++ Library - <iostream>
- C++ Library - <istream>
- C++ Library - <ostream>
- C++ Library - <sstream>
- C++ Library - <streambuf>
- C++ Library - <atomic>
- C++ Library - <complex>
- C++ Library - <exception>
- C++ Library - <functional>
- C++ Library - <limits>
- C++ Library - <locale>
- C++ Library - <memory>
- C++ Library - <new>
- C++ Library - <numeric>
- C++ Library - <regex>
- C++ Library - <stdexcept>
- C++ Library - <string>
- C++ Library - <thread>
- C++ Library - <tuple>
- C++ Library - <typeinfo>
- C++ Library - <utility>
- C++ Library - <valarray>
- The C++ STL Library
- C++ Library - <array>
- C++ Library - <bitset>
- C++ Library - <deque>
- C++ Library - <forward_list>
- C++ Library - <list>
- C++ Library - <map>
- C++ Library - <queue>
- C++ Library - <set>
- C++ Library - <stack>
- C++ Library - <unordered_map>
- C++ Library - <unordered_set>
- C++ Library - <vector>
- C++ Library - <algorithm>
- C++ Library - <iterator>
- C++ Programming Resources
- C++ Programming Tutorial
- C++ Useful Resources
- C++ Discussion
C++ basic_ios Library - sync
Description
It is used to synchronize input buffer.
Declaration
Following is the declaration for std::basic_istream::sync.
int sync();
Parameters
none
Return Value
If the function fails, either because no stream buffer object is associated to the stream (rdbuf is null), or because the call to its pubsync member fails, it returns -1.therwise, it returns zero, indicating success.
Exceptions
Basic guarantee − if an exception is thrown, the object is in a valid state.
Data races
Modifies the stream object.
Example
In below example for std::basic_istream::sync.
#include <iostream> int main () { char first, second; std::cout << "Please, enter a word: "; first = std::cin.get(); std::cin.sync(); std::cout << "Please, enter another word: "; second = std::cin.get(); std::cout << "The first word began by " << first << '\n'; std::cout << "The second word began by " << second << '\n'; return 0; }
The output should be like this −
Please, enter a word: test Please enter another word: text The first word began by t The second word began by t
istream.htm
Advertisements