Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 2nd, 2004, 12:47 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Want to reiterate on my char to int problem

As the Thread title Suggests I am having a problem taking 2 chars (which make up a byte) from the array and placing it into an Integer Variable all the while allowing it to retain its value. I have books here that Explain Type Conversion, but it does not go into Copius Detail on char to int conversion.

The 2 char values I am trying to take from the array will end up being a HEX Value within the Integer Variable.

I am trying to do 2 things:

1). Convert 2 chars from the array into an Integer HEX Value
2). Convert that New HEX Valued Integer to a Decimal Integer Value.

For the Sake of this thread, I will give an example:

RawPacket = 3
RawPacket[9] = 9

Now this comes from the following Data within the array:

Code:
4840200039 |Array Data
----------
0123456789 |Corresponding Array Position
        ^^
        ||
        \         ----------------------Position of 3 and 9
What I want to do is take that 3 and 9, put it together and put 39 into an int variable.

Then take that 39 and convert it into a decimal value which in this case would be 57.

Another Example:

Code:
484020005C |Array Data
----------
0123456789 |Corresponding Array Position
        ^^
        ||
        \         ----------------------Position of 5 and C
What I want to do is take that 5 and C, put it together and put 5C into an int variable.

Then take that 5C and convert it into a decimal value which in this case would be 92.

I have had some algorithms given to me, but none of them worked.

Hopefully someone here can help me if possible.

Thank you

Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Big challenge here! How to convert char* to char^? samiswt Visual C++ 2005 1 November 30th, 2007 09:09 PM
problem Int to Autonumber Irfan_Lateef SQL Server 2000 2 July 9th, 2007 10:57 PM
Convert a char to int!!!!?? vtvb C++ Programming 6 March 18th, 2006 05:51 AM
convert char to int does not work yasaman C# 1 August 6th, 2003 10:39 AM
char problem roelbagao Java Databases 1 July 19th, 2003 12:29 AM



All times are GMT -4. The time now is 03:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.