delete array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 19831030
    New Member
    • Jul 2007
    • 9

    delete array

    Can you pls send me a sample code for delete array in C language.delete key word is not in C language.Isn't it?
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by 19831030
    Can you pls send me a sample code for delete array in C language.delete key word is not in C language.Isn't it?
    Yes, You are right. Delete is a keyword for the same purpose in C++. malloc and free are the functions in C to allocate and deallocate memory respectively. You can use something like this

    Code:
    int* ip;
    ip = (int*)malloc(sizeof(int) * 100);
    ...
    free((void*)ip);
    Regards

    Comment

    • kky2k
      New Member
      • May 2007
      • 34

      #3
      Originally posted by zodilla58
      Yes, You are right. Delete is a keyword for the same purpose in C++. malloc and free are the functions in C to allocate and deallocate memory respectively. You can use something like this

      Code:
      int* ip;
      ip = (int*)malloc(sizeof(int) * 100);
      ...
      free((void*)ip);
      Regards
      just to add..
      u can't delete an array until or unless its dynamically allocated using malloc/calloc..

      Comment

      Working...