•#include
<stdlib.h>
•
•int
*dynArray;
•int
*pInteger;
•
•int
main(int argc, char* argv[])
•{
• // allocating an integer in malloc
style
• pInteger = (int *)malloc(1);
• int integer = *pInteger;
• free(pInteger);
•
• // allocating an array in malloc
style
• dynArray = (int
*)malloc(100);
• integer = dynArray[10];
• free(dynArray);
•
• // allocating an integer in C++
style
• pInteger = new int[1];
• integer = *pInteger;
• delete pInteger;
•
• // allocating an array in C++
style
• dynArray = new int[100];
• integer = dynArray[10];
• delete [] dynArray;
•
• return 0;
•}
•