I am trying to edit my own files with Vi on linux using the following C++ code. I am trying to name the files using character array, but when I am trying to copy from string to a dynamic character array, I get weird characters at the end of the array.What is the reason? How could I fix it? Sorry It didnt let me post the picture so i copied what i had on screen and pasted it Thank you
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