468,133 Members | 1,309 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

syntax problem calling trimstart

I am tring to use trimstart to remove leading zeros, but all things I try
give a compiler error on converting data. I am programing in C++ .net vs2003.
This is one of my earlier attempts to call function
empcode = empcode->TrimStart ('0');
This is result:
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(3 22):
error C2664: 'System::String::TrimStart' : cannot convert parameter 1 from
'char' to '__wchar_t __gc[]'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast

I have tried several ways to declare 0 but have not been able to get it in
right format I did try assigning 0 to a __wchar_t .
Dec 2 '05 #1
2 1957
The problem is that TrimStart can trim more than one character at the same
time, so it expects an array of these characters, not just one. So create an
array of one element, make '0' that one element, and pass this array instead
of passing just '0'...

[==P==]

"brian_harris" <br*********@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
I am tring to use trimstart to remove leading zeros, but all things I try
give a compiler error on converting data. I am programing in C++ .net
vs2003.
This is one of my earlier attempts to call function
empcode = empcode->TrimStart ('0');
This is result:
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(3 22):
error C2664: 'System::String::TrimStart' : cannot convert parameter 1 from
'char' to '__wchar_t __gc[]'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast

I have tried several ways to declare 0 but have not been able to get it in
right format I did try assigning 0 to a __wchar_t .

Dec 2 '05 #2
I had tried initializing as an array but got various other compiler issues,
so I presume that I am not declaring it correct for a managed object

__wchar_t MyChar[] = {'0'};
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(3 27):
error C2664: 'System::String::TrimStart' : cannot convert parameter 1 from
'__wchar_t [1]' to '__wchar_t __gc[]'

char MyChar[] = {'0'};
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(3 27):
error C2664: 'System::String::TrimStart' : cannot convert parameter 1 from
'char [1]' to '__wchar_t __gc[]'

__wchar_t MyChar[] = {"0"};
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(2 85):
error C2440: 'initializing' : cannot convert from 'const char [2]' to
'__wchar_t'
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(3 27):
error C2664: 'System::String::TrimStart' : cannot convert parameter 1 from
'__wchar_t [1]' to '__wchar_t __gc[]'

"Peter Oliphant" wrote:
The problem is that TrimStart can trim more than one character at the same
time, so it expects an array of these characters, not just one. So create an
array of one element, make '0' that one element, and pass this array instead
of passing just '0'...

[==P==]

"brian_harris" <br*********@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
I am tring to use trimstart to remove leading zeros, but all things I try
give a compiler error on converting data. I am programing in C++ .net
vs2003.
This is one of my earlier attempts to call function
empcode = empcode->TrimStart ('0');
This is result:
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(3 22):
error C2664: 'System::String::TrimStart' : cannot convert parameter 1 from
'char' to '__wchar_t __gc[]'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast

I have tried several ways to declare 0 but have not been able to get it in
right format I did try assigning 0 to a __wchar_t .


Dec 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

699 posts views Thread by mike420 | last post: by
37 posts views Thread by Bengt Richter | last post: by
7 posts views Thread by Steven Bethard | last post: by
19 posts views Thread by Nicolas Fleury | last post: by
7 posts views Thread by GrandpaB | last post: by
2 posts views Thread by sjoshi | last post: by
9 posts views Thread by parag_paul | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.