Topic: Why is it that const wstring's begin not equal to const wchar*?
Author: Ron Natalie <ron@sensor.com>
Date: Tue, 4 Dec 2001 19:57:22 GMT Raw View
"news.dsli.com" wrote:
>
> I have a basic question. I have a the following code:
>
> void PrintSomeString(const whcar* pChar, int nSize);
>
What is whcar?
> This gives me an error that pStringChar can't be converted into a const
> char*. This error is in VC.NET. VC++ 6.0 compiled it fine.
Are you sure that PrintSomeString doesn't really define pChar as some
typedef that is different between the two versions of the compiler?
It sounds oddly like it's just "const char*" and you are trying to
cram a wchar_t* into it.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: "Carl Daniel" <cpdaniel@pacbell.net>
Date: Wed, 5 Dec 2001 16:49:37 GMT Raw View
Under VC6, std::wstring iterators happened to be const wchar_t*. Under
VS.NET, they're not. Simple as that.
-cd
To quote from the repose to an identical posting on
microsoft.public.dotnet.languages.vc:
"Jonathan Caves [MSFT]" <no_spam_joncaves@microsoft.com> wrote in message
news:emdd3jOfBHA.1700@tkmsftngp02...
> You could consider this a side-effect of a bug fix.
>
> The iterators in the STL that ships with Visual C++ 7.0 have been made
much
> more conformant to the C++ Standard - this means that you can never use an
> iterator to access an element directly as you could with Visual C++ 6.0.
> Instead you need to "dereference" the iterator. The way to acheive what
you
> want is to use the c_str method on the basic_string class. For example:
> #include <string>
>
> using namespace std;
>
> void PrintSomeCharacter(wchar_t ch);
> void PrintSomeString(const wchar_t *pChar);
>
> void DoSomething(const wstring &string) {
> for (wstring::const_iterator iter = string.begin(); iter !=
string.end();
> iter++) {
> PrintSomeCharacter(*iter);
> }
>
> PrintSomeString(string.c_str());
> }
>
> --
> Jonathan Caves
> Microsoft Corporation
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: "news.dsli.com" <ventruascum@dsli.com>
Date: Tue, 4 Dec 2001 19:36:59 GMT Raw View
I have a basic question. I have a the following code:
void PrintSomeString(const whcar* pChar, int nSize);
void DoSomething(const wstring& string)
{
for (wstring::const_iterator pStringChar = string.begin(); pStringChar
!= string.end(); pStringChar ++)
{
PrintSomeString(pStringChar , 1);
}
}
This gives me an error that pStringChar can't be converted into a const
char*. This error is in VC.NET. VC++ 6.0 compiled it fine.
Scott Andrew
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]