c++源程序:读取一个文本文件中的数据存在一个二维数组中。谢谢,采用加分!

来源:百度知道 编辑:UC知道 时间:2024/09/28 13:30:10
system("pause");
是什么意思?

data.txt:
1 2 3
4 5 6
7 8 9
//read_data.cpp
#include<fstream>
#include<iostream>
using namespace::std;

int main(){
int a,b;//数组大小
cin>>a>>b;
int** m = new int*[a];
for(int i = 0;i < a;++i){
*m = new int[b];
}

ifstream in("data.txt");

for(int i = 0;i < a;++i){
for(int j = 0;j < b;++j){
in>>m[i][j];
}
}
system("pause");
return 0;
}

顾名思义暂停...有些编译器不加上system("pause");命令行窗口会关掉,看不到结果;VC的话就不用