回答編集履歴
1
C\+\+11なら・・・
answer
CHANGED
@@ -14,4 +14,24 @@
|
|
14
14
|
}
|
15
15
|
targetStr = destStr;
|
16
16
|
}
|
17
|
+
```
|
18
|
+
|
19
|
+
---
|
20
|
+
おまけ
|
21
|
+
|
22
|
+
C++11が使えるならムーブにすることで、ちょっとだけ速くなるような気がします。
|
23
|
+
|
24
|
+
```C++
|
25
|
+
void deleteNl2(std::string &targetStr)
|
26
|
+
{
|
27
|
+
const char CR = '\r';
|
28
|
+
const char LF = '\n';
|
29
|
+
std::string destStr;
|
30
|
+
for (const auto c : targetStr) {
|
31
|
+
if (c != CR && c != LF) {
|
32
|
+
destStr += c;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
targetStr = std::move(destStr);
|
36
|
+
}
|
17
37
|
```
|