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

  • Home
  • SEARCH
  • 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 7030223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:38:31+00:00 2026-05-28T00:38:31+00:00

For example, this method: memcpy(pVoid, MyStructArray, sizeof(MyStructArray)); This used to be fine because I

  • 0

For example, this method:

memcpy(pVoid, MyStructArray, sizeof(MyStructArray)); 

This used to be fine because I was calling this method once on instantiation where the array was sa pre-defined size. However it became necessary to change the information in the ‘array’ dynamically, so I’m using a vector instead. Is the information in a vector guaranteed to be contiguous?

could I do something like

 memcpy(pVoid, &MyStructVector, sizeof(*MyStructVector) * MyStrucVector.size()); 
  • 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-28T00:38:32+00:00Added an answer on May 28, 2026 at 12:38 am

    The data in a std::vector is contiguous. But you can’t copy it like you are doing. You can, however, do this:

    memcpy(pVoid, &MyStructVector[0], sizeof(MyStructVector[0]) * MyStrucVector.size()); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, this method from NSCalendar takes a bitmask: - (NSDate *)dateByAddingComponents:(NSDateComponents *)comps toDate:(NSDate
Why in this example from MSDN, in GetEnumerator method, PeopleEnum returns IEnumerator ? public
Example: I have a selector like this, which I give to another method as
This is an example of RegisterClientScriptBlock Page.ClientScript.RegisterClientScriptBlock(Me.GetType, key,scriptblock, True) Why do the method needs
Say for example this is my C ( & Objective-C ) method as follows.
For example this method of Dataset object returns NULL , How do I make
Taking for example this method declaration: const Vector Vector::operator - ( const Vector& other
I have picked up this example which converts BitSet to Byte array. public static
For example this service class' method below: @Transactional public void findDiscountedItems() { List<Item> items
When an UpdatePanel Calls a method in server and for example this method change

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.