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 also stop extracting characters if the end-of-file is reached if the input is taken using a file. This function accesses the input sequence by first constructing a sentry object. It extracts characters from its associated stream buffer object and destroys the sentry object before returning.
istream& ignore(size N, int delim = EOF);
Parameters: It accepts the following parameters:
- N: It represent maximum number of characters to extract.
- delim: It is used for where stop the extraction.
Return Value: It returns the basic_istream object.
Below are the programs to demonstrate basic_istream::ignore():
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- isalpha() and isdigit() functions in C with cstring examples.
- Pointers in C/C++ with Examples
- strtok() and strtok_r() functions in C with examples
- memset() in C with examples
- std::mismatch() with examples in C++
- wcscpy() function in C++ with Examples
- wcscmp() function in C++ with Examples
- set_symmetric_difference in C++ with Examples
- ratio_equal() in C++ with examples
- std::equal_to in C++ with Examples
- quick_exit() function in C++ with Examples
- feclearexcept in C++ with Examples
- Understanding Lvalues, PRvalues and Xvalues in C/C++ with Examples
- multiset lower_bound() in C++ STL with Examples
- multiset upper_bound() in C++ STL with Examples
- multiset max_size() in C++ STL with Examples
- forward_list max_size() in C++ STL with Examples
- std::allocator() in C++ with Examples
- array data() in C++ STL with Examples
- multiset size() in C++ STL with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.