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

来源:互联网 发布:macbook无法下载软件 编辑:程序博客网 时间:2024/06/06 05:23
#include <stdio.h>#include <malloc.h>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) );}//freefor (int j = 0; j < 100; j++){free(rlname[j]);}free(rlname);}

#include <iostream>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;}

0 0
原创粉丝点击