質問編集履歴
2
いらない文が入っていたので、更新しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,17 +52,7 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
```
|
55
|
+
```
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
重黒木夢向 <jukuroki.yuko@gmail.com>
|
60
|
-
|
61
|
-
0:22 (0 分前)
|
62
|
-
|
63
|
-
To 自分
|
64
|
-
|
65
|
-
|
66
56
|
|
67
57
|
#include <stdio.h>
|
68
58
|
|
1
a,i,v,rの機能を実装できましたので更新します
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,6 +54,16 @@
|
|
54
54
|
|
55
55
|
```C
|
56
56
|
|
57
|
+
|
58
|
+
|
59
|
+
重黒木夢向 <jukuroki.yuko@gmail.com>
|
60
|
+
|
61
|
+
0:22 (0 分前)
|
62
|
+
|
63
|
+
To 自分
|
64
|
+
|
65
|
+
|
66
|
+
|
57
67
|
#include <stdio.h>
|
58
68
|
|
59
69
|
#include <stdlib.h>
|
@@ -66,15 +76,15 @@
|
|
66
76
|
|
67
77
|
|
68
78
|
|
69
|
-
#define
|
79
|
+
#define GYO 200 //1ファイルの最大行数
|
70
|
-
|
80
|
+
|
71
|
-
#define
|
81
|
+
#define MOJI 256 //1行の最大文字数
|
82
|
+
|
72
|
-
|
83
|
+
#define LINE line+1
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
84
|
+
|
85
|
+
|
86
|
+
|
77
|
-
int kansu(char* str,FILE* fp);
|
87
|
+
int kansu(char* str,FILE* fp);
|
78
88
|
|
79
89
|
|
80
90
|
|
@@ -84,286 +94,472 @@
|
|
84
94
|
|
85
95
|
|
86
96
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
//strにファイルの内容読込み
|
128
|
-
|
129
|
-
while(fgets(str[i],MOJI,fp)!=NULL){
|
130
|
-
|
131
|
-
//ファイルの行数チェック
|
132
|
-
|
133
|
-
if(i>GYO){
|
134
|
-
|
135
|
-
printf("ファイルの長さが[%d]を超えました",GYO);
|
136
|
-
|
137
|
-
break;
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
if(strlen(str[i])==255){
|
144
|
-
|
145
|
-
if(kansu(str[i],fp)){
|
146
|
-
|
147
|
-
exit(EXIT_FAILURE);
|
148
|
-
|
149
|
-
}
|
150
|
-
|
151
|
-
printf("strlen=[%ld]\n",strlen(str[i]));
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
printf("%d:%s",line,str[i]);
|
158
|
-
|
159
|
-
printf("%ld\n",strlen(str[i]));
|
160
|
-
|
161
|
-
line++;
|
162
|
-
|
163
|
-
i++;
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
int line_max=line-1;//ファイル全体の行数
|
172
|
-
|
173
|
-
while(1){
|
174
|
-
|
175
|
-
printf("コマンドを入力してください:");
|
176
|
-
|
177
|
-
fgets(retsu,sizeof(retsu),stdin);
|
178
|
-
|
179
|
-
//大文字も小文字も対応する処理
|
180
|
-
|
181
|
-
for(k=0;k<strlen(retsu);k++){
|
182
|
-
|
183
|
-
retsu[k]=tolower(retsu[k]);
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
//nコマンドのため
|
188
|
-
|
189
|
-
gyo=atoi(retsu);
|
190
|
-
|
191
|
-
//各コマンドの処理
|
192
|
-
|
193
|
-
if(strchr(retsu,'o')){
|
194
|
-
|
195
|
-
for(int i=0;i<line_max;i++){
|
196
|
-
|
197
|
-
if(i==line-1){
|
198
|
-
|
199
|
-
printf("*%d:%s\n",i+1,str[i]);
|
200
|
-
|
201
|
-
}else{
|
202
|
-
|
203
|
-
printf("%d:%s\n",i+1,str[i]);
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
printf("line:%d\n",line);
|
210
|
-
|
211
|
-
printf("line_max:%d\n",line_max);
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
}else if(strchr(retsu,'d')){
|
216
|
-
|
217
|
-
str[line]==NULL;
|
218
|
-
|
219
|
-
printf("*%d:%s\n",line,str[line]);
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
}else if(strchr(retsu,'a')){
|
226
|
-
|
227
|
-
scanf("%s\n",str[line]);
|
228
|
-
|
229
|
-
line++;
|
230
|
-
|
231
|
-
printf("*%d:%s\n",line,str[line-1]);
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
}else if(strchr(retsu,'i')){
|
236
|
-
|
237
|
-
scanf("%s\n",str[line]);
|
238
|
-
|
239
|
-
line++;
|
240
|
-
|
241
|
-
printf("*%d:%s\n",line,str[line]);
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
}else if(strchr(retsu,'p')){
|
246
|
-
|
247
|
-
if(line<1){
|
248
|
-
|
249
|
-
printf("ファイルの先頭です\n");
|
250
|
-
|
251
|
-
continue;
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
line--;
|
256
|
-
|
257
|
-
printf("*%d:%s\n",line-1,str[line-1]);
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
}else if(strchr(retsu,'n')){
|
262
|
-
|
263
|
-
if(line>line_max){
|
264
|
-
|
265
|
-
printf("最端行数を超えました\n");
|
266
|
-
|
267
|
-
line=line_max;
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
line++;
|
272
|
-
|
273
|
-
printf("*%d:%s\n",line,str[line-1]);
|
274
|
-
|
275
|
-
continue;
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
}else if(strchr(retsu,'s')){
|
280
|
-
|
281
|
-
int p=line-10;
|
282
|
-
|
283
|
-
if(p<1){
|
284
|
-
|
285
|
-
p=1;
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
int n=line+10;
|
290
|
-
|
291
|
-
if(n>line_max){
|
292
|
-
|
293
|
-
n=line_max;
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
for(i=p;i<line;i++){
|
298
|
-
|
299
|
-
printf("%d:%s\n",i,str[i-1]);
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
printf("*%d:%s\n",line,str[line-1]);
|
304
|
-
|
305
|
-
for(i=line+1;i<n+1;i++){
|
306
|
-
|
307
|
-
printf("%d:%s\n",i,str[i-1]);
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
continue;
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
}else if(strchr(retsu,'t')){
|
318
|
-
|
319
|
-
line=1;
|
320
|
-
|
321
|
-
printf("%d:%s\n",line,str[line-1]);
|
322
|
-
|
323
|
-
}else if(strchr(retsu,'l')){
|
324
|
-
|
325
|
-
line=line_max;
|
326
|
-
|
327
|
-
printf("%d:%s\n",line,str[line-1]);
|
328
|
-
|
329
|
-
printf("linemax=%d\n",line_max);
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
}else if(strchr(retsu,'x')){
|
336
|
-
|
337
|
-
printf("終了\n");
|
338
|
-
|
339
|
-
break;
|
340
|
-
|
341
|
-
}else if(gyo<=line_max && gyo>0){
|
342
|
-
|
343
|
-
line=gyo;
|
344
|
-
|
345
|
-
printf("*%d:%s\n",gyo,str[gyo-1]);
|
346
|
-
|
347
|
-
continue;
|
348
|
-
|
349
|
-
}else{
|
350
|
-
|
351
|
-
printf("コマンドが不正です\n");
|
352
|
-
|
353
|
-
continue;
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
}
|
360
|
-
|
361
|
-
fclose(fp);
|
362
|
-
|
363
|
-
exit(EXIT_SUCCESS);
|
97
|
+
FILE* fp;
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
char str[GYO][MOJI];
|
102
|
+
|
103
|
+
char retsu[128];
|
104
|
+
|
105
|
+
int i=0;
|
106
|
+
|
107
|
+
int line=0;//現在の行番号
|
108
|
+
|
109
|
+
int gyo;
|
110
|
+
|
111
|
+
int k;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
if(argc==2){
|
118
|
+
|
119
|
+
if((fp=fopen(argv[1],"r"))==NULL){
|
120
|
+
|
121
|
+
printf("ファイルが開けませんでした\n");
|
122
|
+
|
123
|
+
exit(EXIT_FAILURE);
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
else{
|
130
|
+
|
131
|
+
printf("引数の値が不正です\n");
|
132
|
+
|
133
|
+
exit(EXIT_FAILURE);
|
364
134
|
|
365
135
|
}
|
366
136
|
|
137
|
+
//strにファイルの内容読込み
|
138
|
+
|
139
|
+
while(fgets(str[i],MOJI,fp)!=NULL){
|
140
|
+
|
141
|
+
//ファイルの行数チェック
|
142
|
+
|
143
|
+
if(i>GYO){
|
144
|
+
|
145
|
+
printf("ファイルの長さが[%d]を超えました",GYO);
|
146
|
+
|
147
|
+
break;
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
if(strlen(str[i])==255){
|
154
|
+
|
155
|
+
if(kansu(str[i],fp)){
|
156
|
+
|
157
|
+
exit(EXIT_FAILURE);
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
printf("strlen=[%ld]\n",strlen(str[i]));
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
printf("%d:%s",LINE,str[line]);
|
168
|
+
|
169
|
+
printf("%ld\n",strlen(str[line]));
|
170
|
+
|
171
|
+
line++;
|
172
|
+
|
173
|
+
i++;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
line--;
|
182
|
+
|
183
|
+
int line_max=line;//ファイル全体の行数
|
184
|
+
|
185
|
+
while(1){
|
186
|
+
|
187
|
+
printf("コマンドを入力してください:");
|
188
|
+
|
189
|
+
fgets(retsu,sizeof(retsu),stdin);
|
190
|
+
|
191
|
+
//大文字も小文字も対応する処理
|
192
|
+
|
193
|
+
for(k=0;k<strlen(retsu);k++){
|
194
|
+
|
195
|
+
retsu[k]=tolower(retsu[k]);
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
//nコマンドのため
|
200
|
+
|
201
|
+
gyo=atoi(retsu);
|
202
|
+
|
203
|
+
gyo--;
|
204
|
+
|
205
|
+
//各コマンドの処理
|
206
|
+
|
207
|
+
if(strchr(retsu,'o')){
|
208
|
+
|
209
|
+
for(int i=0;i<line_max;i++){
|
210
|
+
|
211
|
+
if(i==line){
|
212
|
+
|
213
|
+
printf("*%d:%s\n",i+1,str[i]);
|
214
|
+
|
215
|
+
}else{
|
216
|
+
|
217
|
+
printf("%d:%s\n",i+1,str[i]);
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
printf("line:%d\n",LINE);
|
224
|
+
|
225
|
+
printf("line_max:%d\n",line_max+1);
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
}else if(strchr(retsu,'d')){
|
230
|
+
|
231
|
+
if(line==0){
|
232
|
+
|
233
|
+
strcpy(str[line],"");
|
234
|
+
|
235
|
+
printf("配列削除しました\n");
|
236
|
+
|
237
|
+
}else if (line_max==line){
|
238
|
+
|
239
|
+
strcpy(str[line],"");
|
240
|
+
|
241
|
+
line--;
|
242
|
+
|
243
|
+
line_max--;
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
}else{
|
248
|
+
|
249
|
+
for(i=line;0<=(line_max-i);i++){
|
250
|
+
|
251
|
+
strcpy(str[i],str[i+1]);
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
line_max--;
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
printf("*%d:%s\n",LINE,str[line]);
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
}else if(strchr(retsu,'r')){
|
266
|
+
|
267
|
+
if(line<0){
|
268
|
+
|
269
|
+
printf("文字列が入っていません\n");
|
270
|
+
|
271
|
+
continue;
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
printf("Enter sentence:");
|
276
|
+
|
277
|
+
fgets(str[line],MOJI,stdin);
|
278
|
+
|
279
|
+
printf("%d:%s\n",LINE,str[line]);
|
280
|
+
|
281
|
+
continue;
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
}else if(strchr(retsu,'a')){
|
286
|
+
|
287
|
+
if(line<0){
|
288
|
+
|
289
|
+
printf("文字列が入っていません\n");
|
290
|
+
|
291
|
+
continue;
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
for(int i=line_max; i>=line; i--){
|
296
|
+
|
297
|
+
strcpy(str[i+1],str[i]);
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
line_max++;
|
302
|
+
|
303
|
+
line++;
|
304
|
+
|
305
|
+
fgets(str[line],sizeof(str[line]),stdin);
|
306
|
+
|
307
|
+
printf("*%d:%s\n",LINE,str[line]);
|
308
|
+
|
309
|
+
continue;
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
}else if(strchr(retsu,'i')){
|
314
|
+
|
315
|
+
for(int i=line_max;i>=line;i--){
|
316
|
+
|
317
|
+
strcpy(str[i+1],str[i]);
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
line_max++;
|
322
|
+
|
323
|
+
fgets(str[line],sizeof(str[line]),stdin);
|
324
|
+
|
325
|
+
printf("*%d:%s\n",LINE,str[line]);
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
}else if(strchr(retsu,'p')){
|
330
|
+
|
331
|
+
if(line<1){
|
332
|
+
|
333
|
+
printf("ファイルの先頭です\n");
|
334
|
+
|
335
|
+
continue;
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
line--;
|
340
|
+
|
341
|
+
printf("*%d:%s\n",LINE,str[line]);
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
}else if(strchr(retsu,'n')){
|
346
|
+
|
347
|
+
if(line>line_max){
|
348
|
+
|
349
|
+
printf("最端行数を超えました\n");
|
350
|
+
|
351
|
+
line=line_max;
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
line++;
|
356
|
+
|
357
|
+
printf("*%d:%s\n",LINE,str[line]);
|
358
|
+
|
359
|
+
continue;
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
}else if(strchr(retsu,'s')){
|
364
|
+
|
365
|
+
int p=line-10;
|
366
|
+
|
367
|
+
if(p<1){
|
368
|
+
|
369
|
+
p=1;
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
int n=line+10;
|
374
|
+
|
375
|
+
if(n>line_max){
|
376
|
+
|
377
|
+
n=line_max;
|
378
|
+
|
379
|
+
}
|
380
|
+
|
381
|
+
for(i=p;i<=line;i++){
|
382
|
+
|
383
|
+
printf("%d:%s\n",i,str[i-1]);
|
384
|
+
|
385
|
+
}
|
386
|
+
|
387
|
+
printf("*%d:%s\n",LINE,str[line]);
|
388
|
+
|
389
|
+
for(i=line+1;i<n+1;i++){
|
390
|
+
|
391
|
+
printf("%d:%s\n",i+1,str[i]);
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
continue;
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
}else if(strchr(retsu,'f')){
|
400
|
+
|
401
|
+
int x;
|
402
|
+
|
403
|
+
int y;
|
404
|
+
|
405
|
+
int z;
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
/*配列の数値を交換*/
|
410
|
+
|
411
|
+
for(x=0;x<line_max-1;x++){
|
412
|
+
|
413
|
+
str[line]=x;
|
414
|
+
|
415
|
+
for(y=(x+1);y<line_max;y++){
|
416
|
+
|
417
|
+
if(str[y]<str[line])line=y;
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
z=str[line];
|
422
|
+
|
423
|
+
str[line]=str[x];
|
424
|
+
|
425
|
+
str[x]=z;
|
426
|
+
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
if(line>line_max){
|
432
|
+
|
433
|
+
printf("入替えできません\n");
|
434
|
+
|
435
|
+
}
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
printf("%d:%s\n",LINE,str[line]);
|
440
|
+
|
441
|
+
continue;
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
}else if (strchr(retsu, 'v')) {
|
448
|
+
|
449
|
+
char fname[128];
|
450
|
+
|
451
|
+
char c2[5];
|
452
|
+
|
453
|
+
FILE* wfp;
|
454
|
+
|
455
|
+
printf("file name is [%s] ?:[y or n]: ", argv[1]);
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
fgets(c2, sizeof(c2), stdin);
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
if (strchr(c2, 'y')) {
|
464
|
+
|
465
|
+
strcpy(fname, argv[1]);
|
466
|
+
|
467
|
+
} else if (strchr(c2, 'n')) {
|
468
|
+
|
469
|
+
printf("Enter file name:");
|
470
|
+
|
471
|
+
fgets(fname,sizeof(fname),stdin);
|
472
|
+
|
473
|
+
} else if(c2[0] == '\n') {
|
474
|
+
|
475
|
+
continue;
|
476
|
+
|
477
|
+
} else {
|
478
|
+
|
479
|
+
printf("Command Error.[%s]\n",c2);
|
480
|
+
|
481
|
+
continue;
|
482
|
+
|
483
|
+
}
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
if ((wfp = fopen(fname, "w")) == NULL) {
|
488
|
+
|
489
|
+
printf("File open Error:w\n");
|
490
|
+
|
491
|
+
}
|
492
|
+
|
493
|
+
for (i=0; i <= line_max; i++) {
|
494
|
+
|
495
|
+
fprintf(wfp, "%s", str[i]);
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
fclose(wfp);
|
500
|
+
|
501
|
+
printf("Write Finish...\n");
|
502
|
+
|
503
|
+
continue;
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
}else if(strchr(retsu,'t')){
|
510
|
+
|
511
|
+
line=1;
|
512
|
+
|
513
|
+
printf("%d:%s\n",LINE,str[line]);
|
514
|
+
|
515
|
+
}else if(strchr(retsu,'l')){
|
516
|
+
|
517
|
+
line=line_max;
|
518
|
+
|
519
|
+
printf("%d:%s\n",LINE,str[line]);
|
520
|
+
|
521
|
+
printf("linemax=%d\n",line_max+1);
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
}else if(strchr(retsu,'x')){
|
528
|
+
|
529
|
+
printf("終了\n");
|
530
|
+
|
531
|
+
break;
|
532
|
+
|
533
|
+
}else if(gyo<=line_max && gyo>=0){
|
534
|
+
|
535
|
+
line=gyo;
|
536
|
+
|
537
|
+
printf("*%d:%s\n",LINE,str[line]);
|
538
|
+
|
539
|
+
continue;
|
540
|
+
|
541
|
+
}else{
|
542
|
+
|
543
|
+
printf("retsu:%s\n",retsu);
|
544
|
+
|
545
|
+
printf("line:%d\n",line);
|
546
|
+
|
547
|
+
printf("コマンドが不正です\n");
|
548
|
+
|
549
|
+
continue;
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
fclose(fp);
|
558
|
+
|
559
|
+
exit(EXIT_SUCCESS);
|
560
|
+
|
561
|
+
}
|
562
|
+
|
367
563
|
|
368
564
|
|
369
565
|
|
@@ -378,115 +574,117 @@
|
|
378
574
|
|
379
575
|
{
|
380
576
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
577
|
+
int i=254;
|
578
|
+
|
579
|
+
int r=0;
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
printf("str[i]==[%d]\n",(unsigned char)str[i]);
|
584
|
+
|
585
|
+
printf("str[i]==[%c]\n",(unsigned char)str[i]);
|
586
|
+
|
587
|
+
printf("str[i]==[0x%x]\n",(unsigned char)str[i]);
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
if((unsigned char)str[i]=='\n' || str[i]=='\0'){
|
592
|
+
|
593
|
+
printf("改行、NULLを検知する\n");
|
594
|
+
|
595
|
+
return 0;
|
596
|
+
|
597
|
+
}
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
else if((unsigned char)str[i]>=0 && (unsigned char)str[i]<=127){
|
602
|
+
|
603
|
+
printf("00〜7Fに入りました\n");
|
604
|
+
|
605
|
+
str[i+1]=10;
|
606
|
+
|
607
|
+
str[i+2]=0;
|
608
|
+
|
609
|
+
return 0;
|
610
|
+
|
611
|
+
}
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
else if((unsigned char)str[i]>=224 && (unsigned char)str[i]<=239){printf("E0〜EFに入りました\n");
|
618
|
+
|
619
|
+
str[i]=10;
|
620
|
+
|
621
|
+
str[i+1]=0;
|
622
|
+
|
623
|
+
r=fseek(fp,sizeof(char)*-1,SEEK_CUR);
|
624
|
+
|
625
|
+
if(r){
|
626
|
+
|
627
|
+
printf("seekに失敗しました\n");
|
628
|
+
|
629
|
+
return -1;
|
630
|
+
|
631
|
+
}
|
632
|
+
|
633
|
+
return 0;
|
634
|
+
|
635
|
+
}
|
636
|
+
|
637
|
+
else if((unsigned char)str[i]>=128 &&(unsigned char)str[i]<=191){
|
638
|
+
|
639
|
+
printf("80~8Fに入りました\n");
|
640
|
+
|
641
|
+
if((unsigned char)str[i-1]>=128 &&(unsigned char)str[i-1]<=191){
|
642
|
+
|
643
|
+
str[i+1]=10;
|
644
|
+
|
645
|
+
str[i+2]=0;
|
646
|
+
|
647
|
+
return 0;
|
648
|
+
|
649
|
+
}
|
650
|
+
|
651
|
+
else{
|
652
|
+
|
653
|
+
str[i-1]=10;
|
654
|
+
|
655
|
+
str[i]=0;
|
656
|
+
|
657
|
+
return 0;
|
658
|
+
|
659
|
+
r=fseek(fp,sizeof(char)*-2,SEEK_CUR);
|
660
|
+
|
661
|
+
if(r){
|
662
|
+
|
663
|
+
printf("seekに失敗しました\n");
|
664
|
+
|
665
|
+
return -1;
|
666
|
+
|
667
|
+
}
|
668
|
+
|
669
|
+
return 0;
|
670
|
+
|
671
|
+
}
|
672
|
+
|
673
|
+
}
|
674
|
+
|
675
|
+
else if((unsigned char)str[i]>=224 && (unsigned char)str[i]<=239){
|
676
|
+
|
677
|
+
printf("E0〜EFに入りました\n");
|
678
|
+
|
679
|
+
str[i+1]=10;
|
680
|
+
|
681
|
+
str[i+2]=0;
|
682
|
+
|
683
|
+
return 0;
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
}
|
490
688
|
|
491
689
|
}
|
492
690
|
|
@@ -498,10 +696,6 @@
|
|
498
696
|
|
499
697
|
|
500
698
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
699
|
```
|
506
700
|
|
507
701
|
|