質問編集履歴

4

初期値の設定と*(arg+4+m)の箇所などを修正しました。

2019/01/24 03:35

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -70,9 +70,9 @@
70
70
 
71
71
 
72
72
 
73
- static int Cnt1;
73
+ static int Cnt1 = 0;
74
-
74
+
75
- int cnt1;
75
+ int cnt1 = 0;
76
76
 
77
77
 
78
78
 
@@ -134,9 +134,9 @@
134
134
 
135
135
  char Greek[][10] = {"Alpha", "Beta", "Gamma", "Epsilon", "Zeta", "Eta", "Iota", "Kappa", "Mu", "Nu", "Rho", "Tau", "Chi", "omicron"};
136
136
 
137
- static int Cnt2;
137
+ static int Cnt2 = 0;
138
-
138
+
139
- int i;
139
+ int i = 0;
140
140
 
141
141
 
142
142
 
@@ -180,7 +180,9 @@
180
180
 
181
181
  char rest1[10] ;
182
182
 
183
- int i, j, l, m, cnt2;
183
+ int i, j, l, m;
184
+
185
+ int cnt2 = 0;
184
186
 
185
187
  char subscript[][10] = {"<sub>", "</sub>"};
186
188
 
@@ -252,7 +254,9 @@
252
254
 
253
255
  char rest2[10] ;
254
256
 
255
- int i, j, l, m, cnt3;
257
+ int i, j, l, m;
258
+
259
+ int cnt3 = 0;
256
260
 
257
261
  char *superscript[] = {"<sup>", "</sup>"};
258
262
 

3

2019/01/24 03:35

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -132,23 +132,23 @@
132
132
 
133
133
 
134
134
 
135
- char Greek[][10] = {"Alpha", "Beta", "Gamma", "Epsilon", "Zeta", "Eta", "Iota", "Kappa", "Mu", "Nu", "Rho", "Tau", "Chi", "omicron"};
135
+ char Greek[][10] = {"Alpha", "Beta", "Gamma", "Epsilon", "Zeta", "Eta", "Iota", "Kappa", "Mu", "Nu", "Rho", "Tau", "Chi", "omicron"};
136
-
136
+
137
- static int Cnt2;
137
+ static int Cnt2;
138
-
138
+
139
- int i;
139
+ int i;
140
140
 
141
141
 
142
142
 
143
143
  if((*arg == Greek[Cnt2][0]) && ((*(arg+1) == '\0') || (*(arg+1) == '_') || (*(arg+1) == '^'))){
144
144
 
145
- *arg = '&';
145
+ *arg = '&';
146
146
 
147
147
  arg++;
148
148
 
149
- while(Greek[Cnt2][i] != '\0'){
149
+ while(Greek[Cnt2][i] != '\0'){
150
-
150
+
151
- *arg = Greek[Cnt2][i];
151
+ *arg = Greek[Cnt2][i];
152
152
 
153
153
  arg++ ,i++;
154
154
 
@@ -220,13 +220,13 @@
220
220
 
221
221
  for(l=0; l<cnt2; l++){
222
222
 
223
- *(arg-cnt2+4) = rest1[l];
223
+ *(arg-cnt2+4+l) = rest1[l];
224
224
 
225
225
  }
226
226
 
227
227
  for(m=0; subscript[1][m] != '\0'; m++){
228
228
 
229
- *(arg+4) = subscript[1][m];
229
+ *(arg+4+m) = subscript[1][m];
230
230
 
231
231
  }
232
232
 
@@ -250,23 +250,23 @@
250
250
 
251
251
  void get_Superscript(char *arg){
252
252
 
253
- char rest2[10] ;
253
+ char rest2[10] ;
254
-
254
+
255
- int i, j, l, m, cnt3;
255
+ int i, j, l, m, cnt3;
256
-
256
+
257
- char *superscript[] = {"<sup>", "</sup>"};
257
+ char *superscript[] = {"<sup>", "</sup>"};
258
258
 
259
259
  if(*arg == '_'){
260
260
 
261
261
  arg++;
262
262
 
263
- for(i=0; i<=9; i++){
263
+ for(i=0; i<=9; i++){
264
-
265
-
266
-
264
+
265
+
266
+
267
- if(*arg == '\0'){
267
+ if(*arg == '\0'){
268
-
268
+
269
- break;
269
+ break;
270
270
 
271
271
  }
272
272
 
@@ -290,13 +290,13 @@
290
290
 
291
291
  for(l=0; l<cnt3; l++){
292
292
 
293
- *(arg-cnt3+4) = rest2[l];
293
+ *(arg-cnt3+4+l) = rest2[l];
294
294
 
295
295
  }
296
296
 
297
297
  for(m=0; superscript[1][m] != '\0'; m++){
298
298
 
299
- *(arg+4) = superscript[1][m];
299
+ *(arg+4+m) = superscript[1][m];
300
300
 
301
301
 
302
302
 

2

2019/01/24 00:08

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
File without changes

1

発生している問題について記述しました。

2019/01/24 00:03

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,5 @@
1
+ ```C言語
2
+
1
3
  #include <stdio.h>
2
4
 
3
5
  #include <stdlib.h>
@@ -310,7 +312,9 @@
310
312
 
311
313
  }
312
314
 
313
-
315
+ ```
316
+
317
+ **実現したいこと**
314
318
 
315
319
  このコードはなぜ実行できないのでしょうか?
316
320
 
@@ -323,3 +327,11 @@
323
327
  Aなら&Alpha
324
328
 
325
329
  x_1^2ならx<sub>1</sub><sup>2</sup>みたいな感じです
330
+
331
+
332
+
333
+ **発生している問題・エラーメッセージ**
334
+
335
+ eclispeではエラーはでるのですが、例えばコマンドライン引数を、\alpha \beta x_1^2 とした場合、結果は
336
+
337
+ alpha beta x_1^2 と入力のままになります。