Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Mon May 05, 2008 3:52 am Post subject: |
|
|
| Code: | int iCurrPos = filename.length();
do {
iCurrPos = filename.rfind( "\\", iCurrPos );
filename.insert(iCurrPos, "\\");
--iCurrPos;
} while( iCurrPos > 0 ); | Or something..? This one is kinda optimized as far as I know: | Code: | tuomi:(~)(64)% g++ test1.cpp
tuomi:(~)(65)% time ./a.out
\abc\dd\ee\ff\
\\abc\\dd\\ee\\ff\\
0.001u 0.000s 0:00.00 0.0% 0+0k 0+0io 0pf+0w | test1.cpp is the code mentioned above with two cout's.
Btw.. Why to do this: | Code: | char* cstr = new char [filename.size()+1];
strcpy (cstr, filename.c_str());
LoadFile(hEdit, cstr); | Doesn't | Code: | | LoadFile(hEdit, filename.c_str() ); | work? Or does your function LoadFile require a copy of the string? IMO it should be done in the function, not here.. (if you want to make it "re-usable".)
EDIT: | Jani wrote: | | Or.. Switch to C++ and use std::string.replace :P | My bad.. Thought std::string.replace would work just like wxString.replace does, but it didn't: http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringreplace | Code: | | wxString.replace("\\", "\\\\", true); | :)
Oh yeh... Blankrider said in IRC that those backslash thingys weren't the problem, but there were quotation marks around the params, and they caused the problem.
|
|