我正在尝试使用以下C ++代码在Linux上编辑我自己的文件。 我试图命名文件使用字符数组,但是当我试图从string复制到dynamic字符数组,我得到奇怪的字符在数组的末尾。原因是什么? 我怎么修复它? 对不起它没有让我张贴图片,所以我复制了我在屏幕上,并粘贴它谢谢
newPath[0] = 'v'; newPath[1] = 'i'; newPath[2] = ' '; for(int i = 0 ; i < fileName.length(); i++) { stringLenght =3 + i; newPath[stringLenght] = (char)fileName[i]; } cout<<newPath<<" length:"<<fileName.length()<<endl; Files are on current directory are listing below; main.cpp a.cpp a.cpp.#h??? Which file do you want to edit?: a.cpp location: . Locationlength:0 vi a.cpp.# { length:5
Python:转义字符不被解释
如何在控制台应用程序(Linux)中擦除打印的字符?
使用Tectia从窗口传输文件到unix时如何删除ctrl M字符?
CharsetDecoder不能在linux机器上工作
计算可打印的字符
std::cout.operator<<(char*) (你的char[]数组衰变为char* )使用 作为它的终止符。 看来你并没有追加那个null。
几乎和这里一样的问题。