Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:06:58+00:00 2026-06-08T05:06:58+00:00

Next code crushed with munmap_chunk(): invalid pointer #include <iostream> #include <vector> #include <algorithm> using

  • 0

Next code crushed with munmap_chunk(): invalid pointer

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> modules = {3,5,7};
vector<int> remainders = {2,3,2};
vector<int> m_bigs(modules.size());

int main() {
    int m_big = 1;
    for(int r : remainders) { m_big *= r; };
    transform(m_bigs.begin(), m_bigs.end(), remainders.begin(), remainders.end(), [m_big](int m, int r){ cout << m_big / r << endl; return m_big / r; });
    for(int m : m_bigs) { cout << m << endl; };

    return 0;
}

the output is

6
4
6
4
6
0

but expected is

6
4
6
6
4
6

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:07:00+00:00Added an answer on June 8, 2026 at 5:07 am
    template < class InputIterator1, class InputIterator2,
               class OutputIterator, class BinaryOperator >
      OutputIterator transform ( InputIterator1 first1, InputIterator1 last1,
                                 InputIterator2 first2, OutputIterator result,
                                 BinaryOperator binary_op );
    

    You trying to insert elements IN remainders at position remainders.end()… bad idea.

    Correct code will be

    #include <iostream>
    #include <vector>
    #include <algorithm>
    
    using namespace std;
    
    vector<int> modules = {3,5,7};
    vector<int> remainders = {2,3,2};
    vector<int> m_bigs(modules.size());
    
    int main() {
        int m_big = 1;
        for(int r : remainders) { m_big *= r; };
        transform(m_bigs.begin(), m_bigs.end(), remainders.begin(), m_bigs.begin(), [m_big](int m, int r){ cout << m_big / r << endl; return m_big / r; });
        for(int m : m_bigs) { cout << m << endl; };
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the next code: #include <stdio.h> int main(void) { int c; while ((c=getchar())!= EOF)
Someone explain why the next code returns a pointer inside ntdll.dll? GetProcAddress(LoadLibraryA(kernel32.dll), EncodePointer); GetProcAddress(LoadLibraryA(kernel32.dll),
I have next code: int main() { OwnSelect(23, FD_READ | FD_WRITE); // <---- Several
I'm using the next code to do what I'm asking for : private delegate
I have next code: std::cout << (-10 >> 1) << std::endl; std::cout << (-9
I have the next code: t= (int)(Math.random()*8+1)+96; //ascii table if (t!= 96){ choose[(int)(t-97)] =
**the next code should parse a data from a webService to textView; Problem :
The next code runs normally in SQLSERVER but when i change the web.config to
I have next code, <form id=form1 runat=server> <asp:Label runat=server ID=Label1 EnableViewState=false /> <asp:CheckBox runat=server
i have written the next code: public void delete(MyType instance) { List<MyType> myList =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.