delete

This is a discussion on delete within the C++ Programming forums, part of the General Programming Boards category; Code: char *pdest; if (pdest = strstr(rawdata, "\"inbox\"") { delete [] pdest; } what am i doing wrong with that? ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    22

    delete

    Code:
    char *pdest;
    if (pdest = strstr(rawdata, "\"inbox\"") {
       delete [] pdest;
    }
    what am i doing wrong with that?
    when running in debug mode, i get errors:
    "Previous frame inner to this frame (corrupt stack?)"

    it happens at the delete step. am i using the wrong syntax?

    noob out

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You only delete[] what you new[].
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,578
    Well...

    EDIT: Ken got it first and better than I did.

    You are also missing a closing parenthesis, btw
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    22
    thanks

    oh, and the closing ) was there, just bad copy/pasting

    thanks again guys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proper Usage of the delete Operator
    By thetinman in forum C++ Programming
    Replies: 7
    Last Post: 04-26-2007, 12:53 AM
  2. BST delete again, but this time I think I'm close
    By tms43 in forum C++ Programming
    Replies: 9
    Last Post: 11-05-2006, 06:24 PM
  3. delete and delete []
    By Lionel in forum C++ Programming
    Replies: 8
    Last Post: 05-19-2005, 02:52 PM
  4. why is this prog crashing on delete?
    By Waldo2k2 in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 11:17 PM
  5. Problem need help
    By Srpurdy in forum C++ Programming
    Replies: 1
    Last Post: 07-24-2002, 01:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21