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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:01:32+00:00 2026-06-13T02:01:32+00:00

I need to convert an array an place it in a struct that has

  • 0

I need to convert an array an place it in a struct that has a void* element and back to another array:

unsigned short array[size];
//do something to the array

typedef struct ck{

void * arg1;
void * arg2;
void * arg3;


} argCookie;


argCookie myCookie;

myCookie.arg2=malloc(sizeof(array));//alloc the necessary space
memcpy(myCookie.arg2,&array,sizeof(array));//copy the entire array there


//later....


unsigned short otherArray[size];
otherArray=*((unsigned short**)aCookie.arg2);

It happens that this last line won’t compile…
Why is that? obviously I’ve messed up somewhere…

Thank you.

  • 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-13T02:01:33+00:00Added an answer on June 13, 2026 at 2:01 am

    You can’t copy arrays by assigning it a pointer, arrays are not pointers, and you cannot assign to an array, you can only assign to elements of an array.

    You can use memcpy() to copy into your array:

    //use array, or &array[0] in memcpy,
    //&array is the wrong intent (though it'll likely not matter in this case
    memcpy(myCookie.arg2,array,sizeof(array));
    
    //later....
    
    unsigned short otherArray[size];
    memcpy(otherArray, myCookie.arg2, size);
    

    That assumes you know size , otherwise you need to place the size in one of your cookies as well.
    Depending on what you need, you might not need to copy into otherArray, just use the data from the cookie directly:

    unsigned short *tmp = aCookie.arg2;
    //use `tmp` instead of otherArray.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert an array of bytes to another base, namely 85. In
I need to convert one array structure into another array structure. I hope someone
I need to convert array of Objects into a Long/Integer.. Problem is that those
How's that for a catchy title? I need to convert back and forth from
I have problem i need to convert from my Array structure to std::vector<int> ...
I need to convert CString to BYTE array. I don't know why, but everything
I need to convert a navigable map to a 2D String array. Below given
I have a byte array and I need to convert this to a image.
I need to convert a HashMap<String, Object> to an array; could anyone show me
I got an array which contains signed int data, i need to convert each

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.