fill() function in C++ STL with examples
The fill() function in C++ STL is used to fill some default value in a container. The fill() function can also be used to fill values in a range in the container. It accepts two iterators begin and end and fills a value in the container starting from position pointed by begin and just before the position pointed by end.
void fill(iterator begin, iterator end, type value);
- begin: The function will start filling values from the position pointed by the iterator begin.
- end: The function will fill values upto the position just before the position pointed by the iterator end.
- value: This parameter denotes the value to be filled by the function in the container.
NOTE : Notice carefully that ‘begin’ is included in the range but ‘end’ is NOT included.
Return Value: This function does not returns any value.
Below program illustrate the fill() function in C++ STL:
0 0 4 4 4 4 4 0 10 10 10 10 10 10 10 10
My Personal Notes arrow_drop_up
Please Login to comment...