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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:39:13+00:00 2026-06-17T16:39:13+00:00

I have a problem with very simple application which uses a dynamicly allocated array

  • 0

I have a problem with very simple application which uses a dynamicly allocated array of struct. Heres my code:

#include <iostream>
#include <string>
using namespace std;

struct MySimpleStuct
{
    string text;
    int intVal;
    double doubleVal;
};

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    MySimpleStuct *s = new MySimpleStuct[N];
    delete s;
    return 0;
}

And im getting those errors:

*** glibc detected *** ./a.out: munmap_chunk(): invalid pointer: 0x08f3c00c ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb74d5ee2]
/lib/i386-linux-gnu/libc.so.6(+0x765c5)[0xb74d65c5]
/usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdlPv+0x1f)[0xb76d251f]
./a.out[0x80487bf]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb74794d3]
./a.out[0x80486a1]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:07 393313     /home/katie/Desktop/Temp/a.out
08049000-0804a000 r--p 00000000 08:07 393313     /home/katie/Desktop/Temp/a.out
0804a000-0804b000 rw-p 00001000 08:07 393313     /home/katie/Desktop/Temp/a.out
08f3c000-08f5d000 rw-p 00000000 00:00 0          [heap]
b7432000-b7434000 rw-p 00000000 00:00 0 
b7434000-b745e000 r-xp 00000000 08:05 659543     /lib/i386-linux-gnu/libm-2.15.so
b745e000-b745f000 r--p 00029000 08:05 659543     /lib/i386-linux-gnu/libm-2.15.so
b745f000-b7460000 rw-p 0002a000 08:05 659543     /lib/i386-linux-gnu/libm-2.15.so
b7460000-b7603000 r-xp 00000000 08:05 655384     /lib/i386-linux-gnu/libc-2.15.so
b7603000-b7604000 ---p 001a3000 08:05 655384     /lib/i386-linux-gnu/libc-2.15.so
b7604000-b7606000 r--p 001a3000 08:05 655384     /lib/i386-linux-gnu/libc-2.15.so
b7606000-b7607000 rw-p 001a5000 08:05 655384     /lib/i386-linux-gnu/libc-2.15.so
b7607000-b760b000 rw-p 00000000 00:00 0 
b760b000-b7627000 r-xp 00000000 08:05 656309     /lib/i386-linux-gnu/libgcc_s.so.1
b7627000-b7628000 r--p 0001b000 08:05 656309     /lib/i386-linux-gnu/libgcc_s.so.1
b7628000-b7629000 rw-p 0001c000 08:05 656309     /lib/i386-linux-gnu/libgcc_s.so.1
b7629000-b7701000 r-xp 00000000 08:05 791499     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
b7701000-b7702000 ---p 000d8000 08:05 791499     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
b7702000-b7706000 r--p 000d8000 08:05 791499     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
b7706000-b7707000 rw-p 000dc000 08:05 791499     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
b7707000-b770e000 rw-p 00000000 00:00 0 
b7724000-b7728000 rw-p 00000000 00:00 0 
b7728000-b7729000 r-xp 00000000 00:00 0          [vdso]
b7729000-b7749000 r-xp 00000000 08:05 659544     /lib/i386-linux-gnu/ld-2.15.so
b7749000-b774a000 r--p 0001f000 08:05 659544     /lib/i386-linux-gnu/ld-2.15.so
b774a000-b774b000 rw-p 00020000 08:05 659544     /lib/i386-linux-gnu/ld-2.15.so
bf92e000-bf94f000 rw-p 00000000 00:00 0          [stack]
Aborted (core dumped)

And dont even know why? When I dont delete *s, everything is right but its not a solution …

  • 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-17T16:39:13+00:00Added an answer on June 17, 2026 at 4:39 pm

    You use new/delete, new[]/delete[] incorrectly, you should call delete []; as you newed an array:

    MySimpleStuct *s = new MySimpleStuct[N];
    delete [] s;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple JavaScript/jquery code which won't just work correctly. The problem
I have a very simple problem. I have an application which is written in
I have a big problem with very simple code. I need to get a
I have deployed a very simple Grails test app on Cloud Foundry which uses
Problem is I have a very simple WCF REST service, which I wrote starting
I have a rather strange problem. I have a very simple application that reads
I have a very simple cython code which use prange , which works fine
I have a problem with OpenGl ES 2.0. I've designed a very simple framework
I have a very simple problem but cannot find a nice solution. I have
I have a very simple problem, but I can't seem to solve it. I

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.