Concatenating Char Array
Posted on 2001-06-15
I'm writing a routine to rename files in a folder. To do this I'm providing the user an interface to select the path, oldfilename, and newfilename. The program works fine if I require the entire path to be entered. However, if I allow the user to provide a path...c:\ctest\ and then ask for the old and new file...test.txt prog.txt I am having trouble concatenating the path and file to provide...c:\ctest\test.txt as a char array. Here's example of code.
What I ultimately want to achieve is to have program run and change the first character of all files in the folder on the fly. Any help would be appreciated. I looked at using the CString class but could not get it to work either.
cout << "Enter path as c:\\path\\" <<endl;
cin >> p;
cout << "Enter old file ie test.txt. \n";
P[strlen(p)]= oldname; // this is where i get my error
cout << "Enter new file ie prog.txt. \n";
P[strlen(p)]= newname; // this is where i get my error
result = rename(newname,oldname);
error routine here