質問編集履歴
5
コードの改編
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
-
fopen_s(fp, (to_string(i) + ".txt").c_str(), "rt");
|
49
|
+
fopen_s(&fp, (to_string(i) + ".txt").c_str(), "rt");
|
50
50
|
|
51
51
|
|
52
52
|
|
4
コードの改編
test
CHANGED
File without changes
|
test
CHANGED
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
{
|
78
78
|
|
79
|
-
close(fp);
|
79
|
+
fclose(fp);
|
80
80
|
|
81
81
|
break;
|
82
82
|
|
3
コメントアウトの消去
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
char fp_BUFFER[MAX_BUFFER_SIZE];
|
59
|
+
char fp_BUFFER[MAX_BUFFER_SIZE];
|
60
60
|
|
61
61
|
|
62
62
|
|
2
コードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
- 今回使うテキストファイルは,3000行3列で,1000枚近くあります.
|
6
6
|
|
7
7
|
- i = 500 付近ででテキストファイルが開けなくなります.(以下のコードより)
|
8
|
+
|
9
|
+
- クローズ(close(fp);)しています.
|
8
10
|
|
9
11
|
|
10
12
|
|
@@ -24,7 +26,15 @@
|
|
24
26
|
|
25
27
|
```C++
|
26
28
|
|
29
|
+
#define MAX_BUFFER_SIZE 1024;
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
27
35
|
int i;
|
36
|
+
|
37
|
+
|
28
38
|
|
29
39
|
|
30
40
|
|
@@ -32,21 +42,49 @@
|
|
32
42
|
|
33
43
|
{
|
34
44
|
|
35
|
-
while (1)
|
36
|
-
|
37
|
-
{
|
38
|
-
|
39
|
-
|
45
|
+
FILE *fp;
|
40
46
|
|
41
47
|
|
42
48
|
|
43
|
-
|
49
|
+
fopen_s(fp, (to_string(i) + ".txt").c_str(), "rt");
|
44
50
|
|
45
51
|
|
46
52
|
|
47
53
|
|
48
54
|
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
char fp_BUFFER[MAX_BUFFER_SIZE]; //lidar_textfile_line_BUFFER[1024]
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
while (1)
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
if (fgets(fp_BUFFER, MAX_BUFFER_SIZE, fp) != NULL)
|
68
|
+
|
69
|
+
{
|
70
|
+
|
71
|
+
sscanf_s(fp_BUFFER, "%lf\t%lf\t%lf\n", &x, &y, &z);
|
72
|
+
|
73
|
+
}
|
74
|
+
|
49
|
-
|
75
|
+
else
|
76
|
+
|
77
|
+
{
|
78
|
+
|
79
|
+
close(fp);
|
80
|
+
|
81
|
+
break;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
50
88
|
|
51
89
|
}
|
52
90
|
|
@@ -54,7 +92,21 @@
|
|
54
92
|
|
55
93
|
|
56
94
|
|
95
|
+
|
96
|
+
|
97
|
+
i++;
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
if (i == 1000)
|
104
|
+
|
105
|
+
{
|
106
|
+
|
57
|
-
|
107
|
+
break;
|
108
|
+
|
109
|
+
}
|
58
110
|
|
59
111
|
|
60
112
|
|
1
close(fp);を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,6 +50,14 @@
|
|
50
50
|
|
51
51
|
}
|
52
52
|
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
close(fp);
|
58
|
+
|
59
|
+
|
60
|
+
|
53
61
|
}
|
54
62
|
|
55
63
|
```
|