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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:00:28+00:00 2026-05-26T11:00:28+00:00

How to move element in array in order or remove from array? Example: arr[3,3,2,1]

  • 0

How to move element in array in order or remove from array?

Example: arr[3,3,2,1]

move(arr[0],arr[sizeof(arr)]);

arr[3,2,1,3];

I wrote function, but is correctly it ?

void remove(int index, char *arr)
{
    arr[index]=NULL;
    for(int i=index;i<sizeof(arr)-1;i++)
        swap(arr[i],arr[i+1]);
}
  • 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-26T11:00:29+00:00Added an answer on May 26, 2026 at 11:00 am

    This already exists in the C++ standard library (std::rotate), and the C standard library (memmove)

    If you’re using C++, (since it comes with a std::swap function, and C can’t swap with parameters like that):

    void remove(int index, char *arr, int len)
    {
        if (len<=0)
            len = strlen(arr);
        std::rotate(arr+index, arr+index+1, arr+len);
        arr[len-1] = NULL;
    }
    

    Also, in C++, use a std::vector or std::string rather than a naked char* pointer.

    If you’re using C:

    void remove(int index, char *arr, int len)
    {
        if (len<=0)
            len = strlen(arr);
        memmove(arr+index, arr+index+1, len-index-1);
        arr[len-1] = NULL;
    }
    

    If you are using naked char* pointers, always pass a length.

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

Sidebar

Related Questions

function moveAround(){ $('p').append($('#div')); } Above code will move div after p element as a
How can I move elements in an array to the next element eg: x[5]
I want to move element of array present at 1st index to the 5th
How can I make a div element move up and down the page when
I'm doing a chess game. In there, I want to move an element with
I'm writing some code to move dynamically an element on my page. If i
I know how to move up and down an element in jQuery. $(#div).animate({left: +=100},
I would like to move a file or folder from one place to another
How can I search for an element within a nested array. Following is what
I have a function below that is supposed to check if the array contains

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.