Thread: does C have a delete function??

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    63

    does C have a delete function??

    If yes..in which library can it be found?
    Thanks
    A

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    remove() is stdio.h
    unlink() is in unistd.h <-- Unix only

    [edit] I presumed you were talking about deleting files?[/edit]
    Last edited by Hammer; 05-16-2002 at 03:54 AM.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    he may have been askig about heaps:
    Code:
    // Allocate on the heap 
    char* Array = new char[99]; 
    
    //Reclaimed with delete 
    delete [] Array;

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by face_master
    >he may have been askig about heaps:
    >char* Array = new char[99];
    That looks like c++ to me....
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    i just don't knoew anymore what C is and what C++ is !!

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by face_master
    i just don't knoew anymore what C is and what C++ is !!
    The same with me. In school, we were taught C and C++ at the same time. The only difference I know is some obvious things like printf/cout, scanf/cin, malloc/new, free/delete and structure/class...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  7. #7
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    you got taught C++ at school?? Lucky bastard... I don't even think the computer teacher(s) at my school even know HTML! My computer teacher is some old guy who talks about the old computers that took up 20 rooms every lesson and if you havn't done your homework and you don't want him to come around and check it, you just ask him a question that he doesn't know the answer to like "Whats the difference between a Mac and a PC" and he babbles on about nothing for the rest of the lesson I learn/have learned everything I know from books (and a bit from this board )
    Last edited by face_master; 05-16-2002 at 05:12 AM.

  8. #8
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by face_master
    you got taught C++ at school?? Lucky bastard... I don't even think the computer teacher(s) at my school even know HTML! My computer teacher is some old guy who talks about the old computers that took up 20 rooms every lesson and if you havn't done your homework and you don't want him to come around and check it, you just ask him a question that he doesn't know the answer to like "Whats the difference between a Mac and a PC" and he babbles on about nothing for the rest of the lesson I learn/have learned everything I know from books (and a bit from this board )
    -"You lucky, lucky bastard" (Monty Python)

    Anyway, congratulations to your own custom title (400+ posts)
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  9. #9
    Registered User -leech-'s Avatar
    Join Date
    Nov 2001
    Posts
    54

    Angry

    They're only teaching us friggin JAVA... ughgshgh!!ddaqe2!

  10. #10
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >If yes..in which library can it be found?
    If you mean the delete operator in C++ which frees allocated memory then the corresponding C function is free(), found in stdlib.h.
    Code:
    // Allocate on the heap 
    char* Array = new char[99]; 
    
    //Reclaimed with delete 
    delete [] Array;
    Converted to C this would be
    Code:
    /* Allocate memory */
    char *Array = malloc ( 99 * sizeof *Array );
    
    /* Reclaimed with free */
    free ( Array );
    -Prelude
    My best code is written with the delete key.

  11. #11
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    is sizeof a function or an operator? either way it seems to take in weird input, something that no other function can do.

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by ygfperson
    is sizeof a function or an operator? either way it seems to take in weird input, something that no other function can do.
    From the good book (K&R that is)
    The sizeof operator yields the number of bytes required to store an object of the type of its operand......
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by -leech-
    They're only teaching us friggin JAVA... ughgshgh!!ddaqe2!
    Yeah. You wouldn't want to use Java. I mean really, then you don't get to use the arrow operator at all!

    I like Java. For the most part, Java is like C or C++. They have a very similar syntax. If you know one, it's not too hard to be able to read the code of another. Generally speaking anyway.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  4. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM