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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:44:43+00:00 2026-05-28T17:44:43+00:00

I have two doubts about the use of memmove() : When is it preferable

  • 0

I have two doubts about the use of memmove():

  • When is it preferable to use this function instead of using another function (i.e. a created own function)? I’m not sure I have understood properly.
  • The signature of the function is void *memmove(void *dest, const void *src, size_t n). If I have a simple array arr[N], how can I put it into the called function? arr[N] or &arr[N]? The difference is if the array is declared with an initial size or like a pointer? I have this doubt because I saw many examples where is used both.

I hope I explained my doubts in a good way.

edit: I have to delete an element from the array, and then I want to shift the following elements of the deleted one on the left.

  • 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-28T17:44:44+00:00Added an answer on May 28, 2026 at 5:44 pm
    1. memmove may be faster but it probably will never be slower than your own function for copying data around (it’s usually coded in carefully crafted assembly to move stuff around in the most efficient way possible on the current architecture);
    2. it depends on what you want to do with that array… if you want to copy its content to another array arr will suffice (and, as the length parameter, you should do sizeof(*arr)*N where N is the number of elements to copy).

    By the way, if source and destination and the copy are nonoverlapping memcpy may be faster.

    I want to delete an element from the array and shift left the element of the same array.

    int arr[N];
    /* ... */
    /* Let's say you want to remove the element i (error checking on i omitted) */
    memmove(arr+i, arr+i+1, (N-i-1)*sizeof(*arr));
    /* or, if you prefer array indexing over pointer arithmetics: */
    memmove(&arr[i], &arr[i+1], (N-i-1)*sizeof(*arr));
    

    (sizeof(*arr) means “get the size of an element of the array”)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have doubt about this two pattern, like MVC and PAC, which is more
I have two doubts: 1. I would like to add some client side support
having this two classes I always have a doubt of which is the best
I have two applications written in Java that communicate with each other using XML
I have two identical tables and need to copy rows from table to another.
I have been learning about TDD (using JUnit) and I have a doubt about
Sorry If I am being noob, I have this doubt, why do we use
I am wondering how you would approach this problem I have two Taxrates that
I am having this doubt about multi-threading and I have faced lots of questions
i have some doubts about the PL/SQL context, are there: the PL/SQL context is

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.