Mega Code Archive

 
Categories / C++ / Data Type
 

Use new operator to allocate memory for char array

#include <iostream> using namespace std;  int main(void) {    char *pointer;    do {      pointer = new char[10000];      if (pointer)        cout << "Allocated 10,000 bytes\n";      else        cout << "Allocation failed\n";    } while (pointer); }