hi, i want to replace temp.replace
(QString("/"), QString("\"));
Here i am getting error
error C2001: newline in constant
error C2275: 'QString' : illegal use of this type as an expression
How can i replace "/" with "\"
hi, i want to replace temp.replace
(QString("/"), QString("\"));
Here i am getting error
error C2001: newline in constant
error C2275: 'QString' : illegal use of this type as an expression
How can i replace "/" with "\"
By escaping it with another \
:
"\\"
This is a general C/C++ gotcha about how escaping works inside character strings. Since \
is used for escaping and thus has a special meaning inside a string, it should be escaped itself.
The error thrown by your compiler is that it sees the second string constant going until the end of the line, since \"
precludes it from ending the string.
thakns 4 ur answer. But till now i didnt sort my issue. Please check my code
// Convert to a wchar_t*
size_t origsize = strlen(toChar) + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
wchar_t wcstring[newsize];
mbstowcs_s(&convertedChars, wcstring, origsize, toChar, _TRUNCATE);
wcscat_s(wcstring, L"\\*.*\0");
wcout << wcstring << endl; // C:\Documents and Settings\softnotions\Desktop\Release\*.*
SHFILEOPSTRUCT sf;
memset(&sf,0,sizeof(sf));
sf.hwnd = 0;
sf.wFunc = FO_COPY;
//sf.pFrom =wcstring; /* when giving wcstring i am not getting answer */
sf.pFrom = L"C:\\Documents and Settings\\softnotions\\Desktop\\Release\\*.*\0";
wcout << sf.pFrom <<endl; // C:\Documents and Settings\softnotions\Desktop\Release\*.*
Both wcstring and sf.pFrom are same then y not gettng answer when assigning sf.pFrom =wcstring;
The help below is for Qt4 library!
If you need to normalize file absolute path you may use for you needs toNativeSeparators function. Here is the Qt Assistant information about it:
QString QDir::toNativeSeparators ( const QString & pathName ) [static] Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
On Windows, toNativeSeparators("c:/winnt/system32") returns "c:\winnt\system32".
The returned string may be the same as the argument on some operating systems, for example on Unix.
This function was introduced in Qt 4.2.
See also fromNativeSeparators() and separator().