Search code examples
csyntax-highlightingnew-operatordelete-operator

New and Delete Operator?


What i'm asking now is, what does the delete and new operator do in C? I asked this question, when I was just simply thinking about how to allocate memory in C++, and I remembered you use the new and delete keyword, (malloc() and free() in C). But when I type in the new and delete keyword in a .c file. It showed up as a keyword. What exactly is the keywords use in C(Not C++).

UsbDriver *ud = malloc(sizeof(UsbDriver));
free(ud);
new // What is this keyword?(C)
delete // What is this keyword?(C)

Solution

  • You are probably using an editor that supports C and C++. Because new and delete are not part of C.