HI all, In my c++ program, I did the following.

......
class thr
      {private:
               char *d;
......
        public:
               d =new char[35];
....
}
destructor has the line
delete [ ]d;

i get segmentation error 
 *** glibc detected *** /usr/bin/perl: free(): invalid next size (normal): 0x0000 000001bc7120 ***

But if I do the following in class,no error comes.

char *d;
char id[35];

Here I need not delete since it will automatically get deleted when it comes out of scope.I need this data in object functions.So is it wrong if I do this way?

help me out,pls.

Hi, thanks for your time and interest.Actually it is a c++ program used as inline in my perl program.and so I was not able to attach the full code.sorry.
I found that the string in which I concatenated another string, had no null as last character and so the string was taken to a length till it could find a zero and so when deleted, it gave segmentation error.
thanks again
bubye.

This question has already been answered. Start a new discussion instead.