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():
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- cin get() in C++ with Examples
- Pi(π) in C++ with Examples
- std::less in C++ with Examples
- wmemset() in C/C++ with Examples
- std::is_nothrow_default_constructible in C++ with Examples
- std::is_move_constructible in C++ with Examples
- std::is_nothrow_copy_assignable in C++ with Examples
- ratio_not_equal() in C++ with examples
- std::is_member_pointer in C++ with Examples
- std::has_virtual_destructor in C++ with Examples
- C/C++ if else statement with Examples
- std::is_trivially_destructible in C++ with Examples
- ratio_equal() in C++ with examples
- basic_istream::get() in C++ with Examples
- std::equal_to in C++ with Examples
- mbrtoc16() in C/C++ with Examples
- mbrtoc32() in C/C++ with Examples
- Map of Vectors in C++ STL with Examples
- exception::what() in C++ with Examples
- std::unary_negate() in C++ 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.