回答編集履歴
3
関数誤りを修正
test
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
fprintf(ofp, "0x%X", BinaryText[i]);
|
58
58
|
|
59
|
-
strc
|
59
|
+
strcopy(delim, ", ");
|
60
60
|
|
61
61
|
}
|
62
62
|
|
2
行末のカンマが失われるのを修正
test
CHANGED
@@ -42,19 +42,21 @@
|
|
42
42
|
|
43
43
|
fprintf(ofp, "unsigned char BinOut[] = {");
|
44
44
|
|
45
|
+
char[2] delim = "";
|
46
|
+
|
45
47
|
for (i = 0; i < fsize; i++) {
|
48
|
+
|
49
|
+
fprintf(ofp, delim);
|
46
50
|
|
47
51
|
if (i % 16 == 0) {
|
48
52
|
|
49
53
|
fprintf(ofp, "\n");
|
50
54
|
|
51
|
-
} else {
|
52
|
-
|
53
|
-
fprintf(ofp, ", ");
|
54
|
-
|
55
55
|
}
|
56
56
|
|
57
57
|
fprintf(ofp, "0x%X", BinaryText[i]);
|
58
|
+
|
59
|
+
strcat(delim, ", ");
|
58
60
|
|
59
61
|
}
|
60
62
|
|
1
改良版を追記
test
CHANGED
@@ -29,3 +29,39 @@
|
|
29
29
|
|
30
30
|
|
31
31
|
```
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
追記:誰かが「余計なカンマは出さない」と言うので
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
// Make BinOut.
|
42
|
+
|
43
|
+
fprintf(ofp, "unsigned char BinOut[] = {");
|
44
|
+
|
45
|
+
for (i = 0; i < fsize; i++) {
|
46
|
+
|
47
|
+
if (i % 16 == 0) {
|
48
|
+
|
49
|
+
fprintf(ofp, "\n");
|
50
|
+
|
51
|
+
} else {
|
52
|
+
|
53
|
+
fprintf(ofp, ", ");
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
fprintf(ofp, "0x%X", BinaryText[i]);
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
fprintf(ofp, "\n};\n\n");
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
以上、行頭判断形式。
|