std::basic_istream::gcount() in C++ with Examples Last Updated : 21 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The std::basic_istream::gcount() is used to count the characters in the given string. It returns the number of characters extracted by the last unformatted input operation. The unformatted input operation is returned by these function: get(), getline(), ignore(), peek(), read(), etc. Header File: <iostream> Syntax: streamsize gcount() const Parameter: This method doesn't accepts any parameter. Return Value: It returns the number of characters extracted by the last unformatted input operation. Below is the program to illustrate std::basic_istream::gcount(): Program 1: CPP // C++ code to illustrate std::gcount() #include <bits/stdc++.h> using namespace std; // Driver Code int main() { // Initialise array of characters char arr[20]; // Declare string stream istringstream stream("GeeksforGeeks"); // Read the string in string stream stream.read(arr, sizeof arr); // Print the count of characters in // string "GeeksforGeeks" cout << "The count of characters" << " in the string " << " is " << stream.gcount() << endl; return 0; } Output: The count of characters in the string is 13 References: http://www.cplusplus.com/reference/istream/basic_istream/gcount/ Comment More infoAdvertise with us Next Article std::basic_istream::ignore in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads std::basic_istream::ignore in C++ with Examples The std::basic_istream::ignore is used to extracts characters from the input string and discards them including delimiting character, i.e., if the end of the file is reached this function stops extracting characters. The delimiting character is the new line character i.e '\n'. This function will als 2 min read std::basic_istream::getline in C++ with Examples The std::basic_istream::getline is used to extract the characters from stream until end of line or the extracted character is the delimiting character. The delimiting character is the new line character i.e '\n'. This function will also stop extracting characters if the end-of-file is reached if inp 2 min read basic_istream::get() in C++ with Examples The basic_istream::get() is used to get the character. This function returns a one character if available, otherwise it will return end of the file. Header File: <iostream> Syntax: int_type get(); Parameters: The method basic_istream::get() doesnât accept any parameter. Return Value: The metho 2 min read basic_istream::swap() in C++ with Examples The basic_ios::swap(x) is used swap all data members of the base class except for rdbuf(), and swaps the values of the gcount() counters between *this and x. This basic_ios::swap(x) function is a protected function. Below is the syntax and the header file for the same: Header File: #include<iostr 2 min read basic_istream::seekg() in C++ with Examples The basic_stream::seekg() method is used to set position of the next character to be extracted from the input stream. This function is present in the iostream header file. Below is the syntax for the same: Header File: #include<iostream> Syntax: basic_istream& seekg (pos_type pos); Paramet 2 min read basic_istream::unget() in C++ with Examples The basic_istream::unget() is used to unget the character and used to decrease the location by one character and makes the extracted character available for used once again. Header File: <iostream> Syntax: basic_istream& unget(); Parameters: The basic_istream::unget() method doesnât accept 2 min read Like