Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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



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





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