指针,static,const,引用,violate等等

#include 
#include 

int main() {
	char **rlname; 

	//malloc!
	rlname = (char**)malloc(100 * sizeof(char*) );
	for (int j = 0; j < 100; j++)
	{
		rlname[j] = (char*) malloc(30 * sizeof(char) );
	}
	//free

	for (int j = 0; j < 100; j++)
	{
		free(rlname[j]);
	}
	free(rlname);
}

#include 
using namespace std;
int main()
{
	int m, n, **p;
	cin >> m >> n;
	p = new int*[m];
	for (int i = 0; i < m; ++i)//for allocate memory
	{	
		p[i] = new int[n];
		//*p + i = new int[n];//wrong
	}
	//....
	//Process your program;
	for (int j = 0; j < m; ++j)//for free the heap memory
	{
		delete[]p[j];
	}
	delete[]p;
}

你可能感兴趣的:(指针,static,const,引用,violate等等)