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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:10:48+00:00 2026-06-10T10:10:48+00:00

This is my structure which has two integer pointers aV and aT. struct ADJP

  • 0

This is my structure which has two integer pointers aV and aT.

struct ADJP
{
    int *aV;
    int eV;
    int nV;
    int *aT;
    int nT;
};
ADJP *Umb = NULL;

The allocation process of aV and aT is like this..

    for(int i=0; i<nb; i++)
    {
        Umb[i].aV = new int[N];
        for(int j=0; j<n; j++)
            Umb[i].aV[j] = pIn[i].aV[j];
}

I want to remove one specific element from Umb array. for example I want to remove Umb[5], then how can I remove. I have tried with various mathods but got error due to allocated pointers I think. I have tried with follow method but its not working with this kind of struct array. It is working with struct array having no pointers.

int DeleteStructElement(int Index, ADJP *b, int N, int at)
{
    for(int i=Index; i<N-1; i++)
        memmove(&b[i], &b[i+1], (N-at-1)*sizeof*b);     // moving the terms of array
    N--;                                                // updating new size
    return N;
}

Have any idea how to remove an element from my struct array?

  • 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-10T10:10:49+00:00Added an answer on June 10, 2026 at 10:10 am

    You will want to delete the arrays in the deleted element to release their memory:

    delete[] b[Index].aV;
    delete[] b[Index].aT;
    

    Then, you only have to do a single memmove to remove the element.

    memmove(&b[Index], &b[Index+1], (N-Index-1) * sizeof(b[Index])
    

    EDIT: as Mahmoud points out, this doesn’t use the at parameter in DeleteStructElement; I’m not sure what you intended that parameter to do.

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

Sidebar

Related Questions

Using EF4 and Linq I have a data structure which looks like this: parentid
I have this structure which I want to write to a file: typedef struct
I have this Structure the elements of which that I need to write in
In a Python system for which I develop, we usually have this module structure.
I have this array {$man_data} which is structured like 10 > 'Text 8' 14
I have this structure: Activity A has a ViewPager. The pages of a ViewPager
This question actually has two parts. The first part: I've been developing my first
I'm trying to create a file which has the following structure: - Each line
I've got a table which has the usual ParentID, ChildID as it's first two
I have a navigation controller, which has the following structure: Category Item Item Detail

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.