473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Stupid Question : wchar_t to Int

Hi, I think I've got a really dumb question here: I started off with a
String* containing the string "03452". I took this value and converted it
to a __gc[] wchar_t array using ->ToCharArray(). So far so good. Now I've
got an array of single digits. This is what I want.

The first wchar_t array element now contains "0", the first character of my
original string. What I now want to do is convert this to an INT. So
instead of a char "0", it's an INT 0. I can't seem to figure out how to do
this. The closest I get is 48, which is the ASCII value of the char "0".
Please help. I've pulled out so much hair I've hardly got any left. How
can I do this?

Thanks,
/\/\ark

Nov 16 '05 #1
3 5051
"Mark Prenter" <mprenterATtelusDOTnet> wrote in message
news:#0**************@TK2MSFTNGP10.phx.gbl...
What I now want to do is convert this to an INT. So
instead of a char "0", it's an INT 0. I can't seem to figure out how to do this. The closest I get is 48, which is the ASCII value of the char "0".
Please help. I've pulled out so much hair I've hardly got any left. How
can I do this?


Make sure that the character value is greater than or equal to '0' and less
than or equal to '9' then subtract '0'.

Regards,
Will
Nov 16 '05 #2
Cool!!

Thanks,
/\/\ark

P.S. - I also noticed that I should have been using an __wchar_t....not a
wchar_t.
"William DePalo [MVP VC++ ]" <wi***********@mvps.org> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
"Mark Prenter" <mprenterATtelusDOTnet> wrote in message
news:#0**************@TK2MSFTNGP10.phx.gbl...
What I now want to do is convert this to an INT. So
instead of a char "0", it's an INT 0. I can't seem to figure out how to do
this. The closest I get is 48, which is the ASCII value of the char "0". Please help. I've pulled out so much hair I've hardly got any left. How can I do this?


Make sure that the character value is greater than or equal to '0' and

less than or equal to '9' then subtract '0'.

Regards,
Will

Nov 16 '05 #3
Mark Prenter wrote:
P.S. - I also noticed that I should have been using an __wchar_t....not a
wchar_t.


You can also compile with the /Zc:wchar_t compiler switch. wchar_t is a real
type according to the C++ standard. Visual C++ by default makes wchar_t a
typedef for an unsigned short. This switch directs the compiler to use the
standard conforming behavior.

Cheerio!

--
Brandon Bray Visual C++ Compiler
This posting is provided AS IS with no warranties, and confers no rights.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Julius Mong | last post by:
Hi all, I'm doing this: // Test char code wchar_t lookup = {0x8364, 0x5543, 0x3432, 0xabcd, 0xef01}; for (int x=0; x<5; x++) { wchar_t * string = (wchar_t*) malloc(sizeof(wchar_t)); string =...
1
by: Mark Fancy | last post by:
I have a project that I'm trying to get to compile. I need to have the /Tc:wchar_t compile switch in order to use some libraries. I have included the following header files: #include <mapix.h>...
23
by: Steven T. Hatton | last post by:
This is one of the first obstacles I encountered when getting started with C++. I found that everybody had their own idea of what a string is. There was std::string, QString, xercesc::XMLString,...
1
by: jjf | last post by:
Do Standard C's wide characters and wide strings require absolutely that each character be stored in a single wchar_t, or can characters be "multi-wchar_t" in the same way that they can be...
12
by: Jens Theisen | last post by:
Hello, does anyone know which layer is responsible for defining the size of wchar_t? Naturally enough, it's not defined in the language. I looked in the SystemV processor supplement and the...
8
by: Rui Maciel | last post by:
I've just started learning how to use the wchar_t data type as the basis for Unicode strings and unfortunately I'm having quite a bit of problems, both in the C front and the Unicode front. In...
3
by: john | last post by:
As far as I know there is only the type wchar_t. However my compiler compiles both "signed wchar_t" and "unsigned wchar_t". Are there both signed and unsigned wchar_t types?
16
by: Michael Brennan | last post by:
I guess this question only applies to programming applications for UNIX, Windows and similiar. If one develops something for an embedded system I can understand that wchar_t would be unnecessary. ...
5
by: Samant.Trupti | last post by:
Hi, There is one thing I am cofused about.... If I have a declareation say char str; Now if I want to change it to wchar so do I have to change it like .... wchar_t str; or double the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.