How to allocate memory for char array in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

int main()
{
	char *p;

	p = new char[100000];

	if (p)
		cout << "Allocated 100,000 bytes" << endl;
	else
		cout << "Allocation failed" << endl;

	return 0;
}


/*
run:

Allocated 100,000 bytes

*/

 



answered May 20, 2018 by avibootz
...