syntax problem calling trimstart

G

Guest

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(322):
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 .
 
P

Peter Oliphant

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==]
 
G

Guest

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(327):
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(327):
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(285):
error C2440: 'initializing' : cannot convert from 'const char [2]' to
'__wchar_t'
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(327):
error C2664: 'System::String::TrimStart' : cannot convert parameter 1 from
'__wchar_t [1]' to '__wchar_t __gc[]'

Peter Oliphant said:
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 said:
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(322):
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 .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top