c++文件操作和new相关

来源:互联网 发布:淘宝办学生证该搜索啥 编辑:程序博客网 时间:2024/06/16 22:54

ifstream 输入文件流 input file stream 用于从文件读数据(从文件读入)
ofstream 输出文件流 output file stream 用于向文件写数据(输出到文件)

给一个int动态分配存储空间

int *y=new int;*y=10;/////或int *y=new int(10);/////或int *y;y=new int(10);//释放delete y;

一维数组:

float *x=new float[n];//释放delete []x;

对每个数组元素的访问为x[0],x[1]….

0 0
原创粉丝点击