回答編集履歴

1

サンプルコードのインデントを揃えた。

2019/12/10 11:56

投稿

dodox86
dodox86

スコア9254

test CHANGED
@@ -36,47 +36,47 @@
36
36
 
37
37
  {
38
38
 
39
- int nRetCode = 0;
39
+ int nRetCode = 0;
40
40
 
41
41
 
42
42
 
43
- // MFC の初期化および初期化失敗時のエラーの出力
43
+ // MFC の初期化および初期化失敗時のエラーの出力
44
44
 
45
- if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
45
+ if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
46
46
 
47
- {
47
+ {
48
48
 
49
- fprintf(stderr, "Fatal Error: MFC initialization failed\n");
49
+ fprintf(stderr, "Fatal Error: MFC initialization failed\n");
50
50
 
51
- nRetCode = 1;
51
+ nRetCode = 1;
52
52
 
53
- }
53
+ }
54
54
 
55
- else
55
+ else
56
56
 
57
- {
57
+ {
58
58
 
59
- CString str("Initial String.");
59
+ CString str("Initial String.");
60
60
 
61
61
 
62
62
 
63
- printf("#1: size of TCHAR=%d\n", sizeof(str[0]));
63
+ printf("#1: size of TCHAR=%d\n", sizeof(str[0]));
64
64
 
65
- printf("#2: length=%d\n", str.GetLength());
65
+ printf("#2: length=%d\n", str.GetLength());
66
66
 
67
- printf("#3: str [%s]\n", (const char*)str);
67
+ printf("#3: str [%s]\n", (const char*)str);
68
68
 
69
69
 
70
70
 
71
- // 10文字分に切り詰め
71
+ // 10文字分に切り詰め
72
72
 
73
73
  char* pref = str.GetBufferSetLength(10);
74
74
 
75
- printf("#4: length=%d\n", str.GetLength());
75
+ printf("#4: length=%d\n", str.GetLength());
76
76
 
77
77
 
78
78
 
79
- *(pref + 0) = '0';
79
+ *(pref + 0) = '0';
80
80
 
81
81
  *(pref + 1) = '1';
82
82
 
@@ -98,69 +98,67 @@
98
98
 
99
99
 
100
100
 
101
- int i;
101
+ int i;
102
102
 
103
- printf("#5: --------\n");
103
+ printf("#5: --------\n");
104
104
 
105
- for (i = 0; i < str.GetLength(); i++) {
105
+ for (i = 0; i < str.GetLength(); i++) {
106
106
 
107
- printf("%02x ", (unsigned char)*(pref + i));
107
+ printf("%02x ", (unsigned char)*(pref + i));
108
108
 
109
- }
109
+ }
110
110
 
111
111
  printf("\n");
112
112
 
113
113
 
114
114
 
115
- printf("#6: str=[%s]\n", (const char*)str);
115
+ printf("#6: str=[%s]\n", (const char*)str);
116
116
 
117
117
  str.ReleaseBuffer();
118
118
 
119
119
 
120
120
 
121
- // CString.ReleaseBuffer(); の実行後
121
+ // CString.ReleaseBuffer(); の実行後
122
122
 
123
- printf("#7: length=%d\n", str.GetLength());
123
+ printf("#7: length=%d\n", str.GetLength());
124
124
 
125
- printf("#8: alloc length=%d\n", str.GetAllocLength());
125
+ printf("#8: alloc length=%d\n", str.GetAllocLength());
126
126
 
127
127
  printf("#9: --------\n");
128
128
 
129
129
  for (i = 0; i < str.GetLength(); i++) {
130
130
 
131
- printf("%02x ", (unsigned char)str[i]);
131
+ printf("%02x ", (unsigned char)str[i]);
132
+
133
+ }
134
+
135
+ printf("\n");
136
+
137
+
138
+
139
+ printf("#10: ------\n");
140
+
141
+ // CString.GetBuffer()でバッファー内を覗いてみる
142
+
143
+ pref = str.GetBuffer(str.GetAllocLength());
144
+
145
+ for (i = 0; i < str.GetAllocLength(); i++) {
146
+
147
+ printf("%02x ", (unsigned char)*(pref + i));
148
+
149
+ }
150
+
151
+ printf("\n");
152
+
153
+ str.ReleaseBuffer();
132
154
 
133
155
  }
134
156
 
135
- printf("\n");
136
157
 
137
158
 
138
-
139
- printf("#10: ------\n");
140
-
141
- // CString.GetBuffer()でバッファー内を覗いてみる
142
-
143
- pref = str.GetBuffer(str.GetAllocLength());
144
-
145
- for (i = 0; i < str.GetAllocLength(); i++) {
146
-
147
- printf("%02x ", (unsigned char)*(pref + i));
148
-
149
- }
150
-
151
- printf("\n");
152
-
153
- str.ReleaseBuffer();
154
-
155
- }
156
-
157
-
158
-
159
- return nRetCode;
159
+ return nRetCode;
160
160
 
161
161
  }
162
-
163
-
164
162
 
165
163
  ```
166
164
 
@@ -198,6 +196,4 @@
198
196
 
199
197
  30 31 32 33 00 f5 f6 f7 f8 f9 00 69 6e 67 2e
200
198
 
201
-
202
-
203
199
  ```