Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,919 questions

51,852 answers

573 users

How to clear part of array element in C++

1 Answer

0 votes
#include <iostream>
#include <array>

int main() {
    std::array<int, 7> arr {1, 2, 3, 4, 5, 6, 7};

    for (const auto &item : arr) {
        std::cout << item << " ";
    }
    std::cout << "\n";

    std::fill(arr.begin(), arr.begin() + 3, 0);

    for (const auto &item : arr) {
        std::cout << item << " ";
    }
 
    return 0;
}
     
     
    
     
     
/*
run:
   
1 2 3 4 5 6 7 
0 0 0 4 5 6 7 
      
*/

 



answered May 12, 2021 by avibootz

Related questions

1 answer 107 views
107 views asked May 12, 2021 by avibootz
1 answer 119 views
119 views asked Aug 4, 2022 by avibootz
2 answers 82 views
1 answer 86 views
86 views asked Jul 9, 2024 by avibootz
1 answer 122 views
...