ifstream 读取文件有行数限制么?
小白一枚,我要从 hist_T600.dat 文件中读取数据存到数组int N[70]中, 文件数据如下:0.18 0
0.181 3570
等等,每行有一个浮点型和一个整型数据,我要做的是把整型数据读到N数组中,代码部分如下:
ifstream fin("hist_T600.dat");
int N[70];
double dou;
for(int i=0;i<50;i++){
fin>>dou;
fin>>N[i];
cout<<i<<":"<<N[i]<<endl;
}
fin.close();
结果输出如下:
0:3570
1:12676
2:50218
3:47079
4:23463
5:25353
6:27872
7:14793
8:19819
9:45026
10:45367
11:43660
12:35543
13:34554
14:27698
15:31466
16:33279
17:34643
18:31194
19:31155
20:27832
21:26640
22:27987
23:26561
24:26730
25:24541
26:24276
27:22356
28:19728
29:19225
30:18390
31:15636
32:15406
33:12748
34:12039
35:10490
36:8813
37:8168
38:6505
39:5382
40:4367
41:3724
42:2841
43:2242
44:1965
45:1413
46:1206
47:1074
48:713
49:542
50:447
51:313
52:329
53:279
54:184
55:76
56:86
57:45
58:50
59:39
60:24
61:17
62:80
63:47
64:16
65:0
66:0
0:3570
1:0
2:0
3:47079
4:23463
5:25353
6:27872
7:14793
8:19819
9:45026
10:45367
11:43660
12:35543
13:34554
14:27698
15:31466
16:33279
17:34643
18:31194
19:31155
20:27832
21:26640
22:27987
23:26561
24:26730
25:24541
26:24276
27:22356
28:19728
29:19225
30:18390
31:15636
32:15406
33:12748
34:12039
35:10490
36:8813
37:8168
38:6505
39:5382
40:4367
41:3724
42:2841
43:2242
44:1965
45:1413
46:1206
47:1074
48:713
49:542
50:447
51:313
52:329
53:279
54:184
55:76
56:86
57:45
58:50
59:39
60:24
61:17
62:0
63:1070596096
64:16
65:1071533075
66:0
67:67
68:1534035128
69:10923
不是我粘贴错误啊,显示到66行之后又跳到0行了,并且后面的显示全错了。这个是怎么回事啊?怎么破?不胜感激。