Assuming list is some structure
list *temp;
temp = new list;
the above is in c++, does this have an equivalent in C?
Assuming list is some structure
list *temp;
temp = new list;
the above is in c++, does this have an equivalent in C?
list *temp;
temp = malloc(sizeof(list));
[...]
free(temp);
C doesn't have the new
keyword - you've got to allocate and free the memory you'd like to use manually. new
also does some work behind the scenes, like calling constructors and returning the proper pointer type - malloc
doesn't cover that, and has to be handled by the programmer.