There’s no new
/delete
expression in C.
The closest equivalent are the malloc
and free
functions, if you ignore the constructors/destructors and type safety.
#include <stdlib.h> int* p = malloc(sizeof(*p)); // int* p = new int; ... free(p); // delete p; int* a = malloc(12*sizeof(*a)); // int* a = new int[12]; ... free(a); // delete[] a;
Related Posts:
- Is “delete this” allowed in C++?
- What exactly is the difference between “pass by reference” in C and in C++?
- Convert char to int in C and C++
- How big can a 64 bit unsigned integer be?
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- Implementing Taylor Series for sine and cosine in C
- Working on code to calculate cosine with factorial sum
- How to use execvp()
- How to use execvp() to execute a command
- How does strtok() split the string into tokens in C?
- warning: implicit declaration of function
- warning: implicit declaration of function
- How to dynamically allocate arrays in C++
- What is *(uint32_t*)?
- What does (~0L) mean?
- How to dynamically allocate arrays in C++
- pthread_join() and pthread_exit()
- What is the difference between float and double?
- what is Segmentation fault (core dumped)? [duplicate]
- What causes a segmentation fault (core dump) to occur in C?
- uint8_t vs unsigned char
- How to use symbols of extended ASCII table in C?
- Two questions about basic C programs
- What is the difference between ++i and i++?
- Using boolean values in C
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- How to print in C
- What is the effect of extern “C” in C++?
- Why should we typedef a struct so often in C?
- Why are #ifndef and #define used in C++ header files?
- What is a string of hexadecimal digits?
- Why should we typedef a struct so often in C?
- What is the difference between ++i and i++?
- What can be the reasons of connection refused errors?
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- What is newline character — ‘\n’
- When to use extern “C” in simple words? [duplicate]
- Floating point exception( core dump
- Why does ENOENT mean “No such file or directory”?
- What does the question mark character (‘?’) mean?
- Cannot figure out how to use getchar(); in C
- Floating point exception (core dumped)
- Expression must have class type
- Undefined reference to pthread_create in Linux
- what is the difference between uint16_t and unsigned short int incase of 64 bit processor?
- makefile:4: *** missing separator. Stop
- Stack smashing detected
- Why am I getting “void value not ignored as it ought to be”?
- Correct format specifier for double in printf
- Stack smashing detected
- How do I determine the size of my array in C?
- Why am I getting “void value not ignored as it ought to be”?
- Mutex example / tutorial? [closed]
- Pointer Arithmetic
- dereferencing pointer to incomplete type
- 1 = false and 0 = true?
- c stack smashing detected
- What does “dereferencing” a pointer mean?
- Openssl : error “self signed certificate in certificate chain”
- How to convert a string to integer in C?
- What is the difference between C and embedded C?
- What is an unsigned char?
- What does “dereferencing” a pointer mean?
- Meaning of = delete after function declaration
- Get a substring of a char* [duplicate]
- char *array and char array[]
- How do I create an array of strings in C?
- Undefined reference to pthread_create
- What is the behavior of integer division?
- Why use conio.h?
- Get a substring of a char*
- Difference between malloc and calloc?
- What is Bit Masking?
- How do function pointers in C work?
- How to track down a “double free or corruption” error
- Convert an int to ASCII character
- Expression must be a modifiable L-value
- What causes the Broken Pipe Error?
- Use new operator to initialise an array
- segmentation fault : 11
- Strings and character with printf
- How to track down a “double free or corruption” error
- Awesomium sdk download
- Why unsigned int 0xFFFFFFFF is equal to int -1?
- What is the significance of return 0 in C and C++?
- What is EOF in the C programming language?
- What are .a and .so files?
- Why does the terminal show “^[[A” “^[[B” “^[[C” “^[[D” when pressing the arrow keys in Ubuntu?
- So what does “return 0” actually mean?
- “Expected expression before ‘ { ‘ token”
- Bad File Descriptor with Linux Socket write() Bad File Descriptor C
- How to generate a random int in C?
- How do I use valgrind to find memory leaks?
- How to go from fopen to fopen_s