需要测试变量删除引号。怎么样?
char test[] = "\"C:\\hello\"";
if(test[0] = '"')
{
// test variable 0 index to blank
}
答案 0 :(得分:1)
由于您使用的是Windows,请调用Windows API中的PathUnquoteSpaces函数。
PathUnquoteSpaces(test);
答案 1 :(得分:0)
要删除字符数组中的字符,您需要使用剩余文本覆盖插槽。
原文:
+---+---+---+----+
| " | C | : | \0 |
+---+---+---+----+
|
+---+ Copy from original.
|
V
+---+---+----+----+
| C | : | \0 | \0 |
+---+---+----+----+
当目的地重叠时,请参阅memmove
进行复制。
更简单的解决方案是对所有多字符文本及其方法使用std::string
。