指针,static,const,引用,violate等等
2014-07-11 10:38
302 查看
#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) ); } //free for (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 ; //*p + i = new int ;//wrong } //.... //Process your program; for (int j = 0; j < m; ++j)//for free the heap memory { delete[]p[j]; } delete[]p; }
相关文章推荐
- C++知识点总结(上):指针和引用,static关键字,const关键字,malloc\free和new\delete的区别等
- 总结1->sizeof-默认值参数的函数-static-指针和引用概念-const-CAS
- C++-const_cast只能用于指针和引用,对象的const到非const可以用static_cast
- C++中的几个关键字(static、const、#define、inline、sizeof与strlen、指针与引用、new与malloc)
- C++系列——const,引用,指针用法小结
- C++(常)引用,const,指针引用
- C++ const限定符之顶层const & 底层const & 指针 & 引用之间的关系
- C和C++中const的区别,引用,一级指针和const组合
- // 程序员面试宝典 62页 ,指针,引用,const常量定以后立即初始化。
- static_cast、dynamic_cast、reinterpret_cast、const_cast,指针,数据类型的强制转换
- 关于指针、const、typedef、作用域::、引用&的一些理解
- const修饰指针和引用的用法
- const与指针、引用
- C++中const与指针、引用的分析(转自china_unix GP-King)
- 【C++】C++基础:指针__引用__const
- 《C++语言基础》实践项目——指针、const、static
- 指针与引用的初始化&顶层底层const变量初始化问题
- 【一天一篇CPP】对象与指针与数组 对象和const和指针和引用
- 关于const 修饰变量、引用、指针的说明
- PHP中的一些关键字(const static define 等等)