Thread: Deleting Variable Data

  1. #1
    Registered User
    Join Date
    Feb 2006

    Deleting Variable Data

    How can one delete variable data at a certain point in the code?

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    New York
    It depends on what one means by deleting variable data I suppose.

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Portland, Or
    If you are trying to just save memory, then put the variable in a function(or in some other way that changes it's scope) along with the code that uses it.

    If you are meaning to clear the data in it (this does not save space because the space for the variable is already reserved) then you can just set it to 0, or in the case of strings and char arrays "".

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Or if the variable is allocated on the heap with new, delete it.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read multiple data for one declared variable
    By c++dummy in forum C++ Programming
    Replies: 3
    Last Post: 11-04-2007, 02:13 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  4. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM