How can I put the ; in a string?
Printable View
How can I put the ; in a string?
This inserts a ';' in the second position (in place of the 'i' in "This"). The CString class has a similar function (called, "Insert").Code:std::string myStr = "This is my string";
myStr.insert(2, ';');
Viggy
Quote:
Originally Posted by dave18285
Code:CString str = ";";
why do I getCode:temptext.Replace(_T("&"), _T('&'));
ObitText.cpp(187) : error C2143: syntax error : missing ')' before ';'
The ';' is not a special character in strings (like '\' is). So, that's not your problem. I think the problem might be the single quotes around the second parameter (the "_T('&')"). Whatever the _T macro expands to, it's not expecting a single character? I don't use UNICODE, so I tend to not use these macros.
Viggy
is correct.Code:temptext.Replace(_T("&"), _T("&"));
Just for future reference, _T prepends an L to a string literal if _UNICODE is defined, to indicate that the string should be interpreted as Unicode, and does nothing if _UNICODE is not defined. So assuming he's not working in Unicode:Quote:
Originally Posted by MrViggy
temptext.Replace(_T("&"), _T('&'));
is equivalent to:
temptext.Replace("&", '&');
So the problem is as Siddhartha pointed out; he was trying to use a character where a string was expected.
yea, changing from single to double quotes worked. thanks for the help