-
Re-formatting a filename
My question here is this. Lets say I store a filename into a CString, or an array. Then, I want to find all the "_" or "-"'s in the filename, and with each one found, replace it w/ a " " (space)?
When I searched this board, I couldn't come up with anything helpful.
-
For the CString you would look at the CString documentation and find a likely method. I'd suggest something like Replace.
For a normal char * string, you would loop through all the characters and replace as needed:
Code:
for (int i = 0;szFileName[i] != '\0';i++)
{
if (szFileName[i] == '_') szFileName[i] = ' ';
}
-
try this
// c - the filename
while ( *c )
{
if (*c == '_') *c = ' ';
}