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 6925781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:50:01+00:00 2026-05-27T10:50:01+00:00

I am very familiar with Java and this is allowed there. However it looks

  • 0

I am very familiar with Java and this is allowed there. However it looks like it’s not with C++. I’m getting an “invalid array assignment” when trying to assign valuesToGrab = updatingValues;.

//these are class attributes
int updatingValues[361] = {0};
int valuesToGrab[361] = {0};

//this is part of a function that is causing an error. 
for (unsigned int i=0; i < 10; i++) {

    //this fills values with 361 ints, and num_values gets set to 361. 
    sick_lms.GetSickScan(values,num_values);

    //values has 361 ints, but a size of 2882, so I copy all the ints to an array
    //of size 361 to "trim" the array.
    for(int z = 0; z < num_values; z++){
        updatingValues[z] = values[z];
    }

    //now I want to assign it to valuesToGrab (another program will be 
    //constantly grabbing this array, and it can't grab it while it's being
    //populated above or there will be issues
    valuesToGrab = updatingValues; // THROWING ERROR
}

I don’t want to have to iterate through updatingValues and add it to valuesToGrab one by one, but if I have to I will. Is there a way I can assign it in one function with C++?

Thanks,

  • 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-05-27T10:50:02+00:00Added an answer on May 27, 2026 at 10:50 am

    The standard idiom for copying in C++ is

    #include <algorithm>
    ...
    std::copy(values, values+num_values, updatingValues);
    

    make sure updatingValues is large enough or you will get overruns and bad things will happen.

    That said in C++ we generally use a std::vector for this sort of task.

    #include <vector>
    ...
    std::vector<int> updatingValues=values; //calls vectors copy constructor
    

    I vector does everything an array does (including static initalization in C++11), but has a well define interface. with iterators, size, empty, resize, push_back and more.

    http://en.cppreference.com/w/cpp/algorithm/copy

    http://en.cppreference.com/w/cpp/container/vector

    EDIT
    It is also worth noting that you can combine vector and arrays.

    std::vector<int> vect(my_array, my_array+10);
    //or
    std::vector<int> another_vector;
    ...
    another_vector.assign(my_array, my_array+10);//delayed population
    

    and visa-versa

    std::copy(vect.begin(), vect.end(), my_array); //copy vector into array.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have not used jquery much yet and not very familiar with it. Trying
I'm writing an android apps in Java of Eclipse. I'm not very familiar with
I'm a Java coder and not very familiar with how networks work (other than
Note: this won't make any sense unless you're very familiar with Java, Spring AOP,
I am not very familiar with java-script/ jquery. i am creating a sliding social
I'm trying implement my project in Apache Struts 2 but I'm not very familiar
I'm not very familiar with wrapping between Java and C++. But i need to
This must be something very basic. I'm not familiar with the syntax, and this
I am very familiar with vlookup and hlookup functions in Excel. However, I am
I am not very familiar with databases and the theories behind how they work.

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.