韩国拼花地板:在vc中怎样将.txt文件的数据转化为数组的形式

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/06 04:46:26
下面是我的数据格式:要全部提取为整型数组,拜托了,帮忙呀,数组的个数不是固定的
258 282 513 21:35:59:906 0
258 282 514 21:35:59:968 1
234 326 513 21:36:00:250 0
234 326 514 21:36:00:328 1
322 90 513 21:36:00:671 0
322 90 514 21:36:00:734 1
547 93 513 21:36:01:015 0
547 93 514 21:36:01:078 1
230 220 513 21:36:01:390 0
230 220 514 21:36:01:484 1
268 145 513 21:36:01:828 0
268 145 514 21:36:01:921 1
187 185 513 21:36:02:140 0
187 185 514 21:36:02:203 1
163 275 513 21:36:02:500 0
163 275 514 21:36:02:593 1
312 330 513 21:36:02:875 0
312 330 514 21:36:02:937 1
258 179 513 21:36:03:156 0
258 179 514 21:36:03:234 1
203 229 513 21:36:03:484 0
203 229 514 21:36:03:546 1
355 174 513 21:36:03:796 0
具体点,谢谢

用CARRAY

#define m 10
#define n 20
main()
{
int i,j,int a[i][j];
printf("请输入:\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d\n",a[i][j]);
printf("%d\n",a[i][j])
}
不知道对不?

// 文件读写.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream.h>
#include <fstream.h>

void main()
{
fstream file1;
file1.open("Ex_Datafile.txt",ios::in);
if(!file1)
{
cout<<"Ex_Datafile.txt不能打开!\n";
return;
}
fstream file2;
file2.open("Ex_DatafileBak.txt",ios::out|ios::trunc);
if(!file2)
{
cout<<"Ex_DatafileBak.txt不能创建!\n";
file1.close();
return;
}
char ch;
while(!file1.eof())
{
file1.read(&ch,1);
cout<<ch;
file2.write(&ch,1);
}
file2.close();
file1.close();
}
在里边修改下应该可以