-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfillFunc.cpp
More file actions
33 lines (23 loc) · 789 Bytes
/
fillFunc.cpp
File metadata and controls
33 lines (23 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
int main() {
int numbers[10];
// Fill the array with the value 5 int.
std::fill(numbers, numbers + 10, 5);
std::cout << "Array after fill: ";
for (int i = 0; i < 10; ++i) {
std::cout << numbers[i] << " ";
}
std::cout << std::endl;
const int size = 100;
std::string yoos[size];
// Fill the array with the value "Yoo..." & "Loo..." string.
std::fill(yoos, yoos + (size/2), "Yoo...");
// first arg is the start of the array, second arg is the end of the array.
std::fill(yoos + (size/2), yoos + size, "Loo...");
std::cout << "Array after fill: ";
for (int i = 0; i < size; ++i) {
std::cout << yoos[i] << " ";
}
std::cout << std::endl;
return 0;
}