Difference between fill() and fill_n() functions in C++ STLFill() and Fill_n() are two functions in the C++ Standard Template Library (STL) that are used to fill a range of elements in a container with a given value. However, they differ somewhat in terms of functionality and use. In this article, we will discuss difference between Fill() and Fill_n() method in C++. But before discussing their differences, we must know about the Fill() and Fill_n() method. What is the std::fill() method?
Syntax:It has the following syntax: Example:Let us take an example to illustrate the std::fill() method in C++. Output: What is the std::fill_n() method?
Syntax:It has the following syntax: Example:Let us take an example to illustrate the std::fill_n() method in C++. Output: Main differences between fill() and fill_n() method:There are several differences between the fill() and fill_n() method. Some main differences between these methods are as follows:
Next TopicDinic's algorithm in C++ |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India