Converting HEX in a string to DEC

Hi, I am having difficulties to convert a HEX number, that I am getting in a array, to the corresponding Decimal number.
This is the part of the code that I need help:

#define ARYSZ2 32
int ch, datary2[ARYSZ2];
int dcnt2=0;

while( Serial3.available() > 0) {
ch=Serial3.read();
if( dcnt2 < ARYSZ2 ){
datary2[dcnt2++]=ch;
}
delay(10);

for( int i=0; i<dcnt2; i++)
{
Serial.write( datary2 );
}
[/td]
[/tr]
[/table]
Anyone could help me on what can I do to show the value of datary2 in Decimal ?

Serial.print (datary2, DEC)
vs
Serial.write( datary2 );

Serial.print (datary2[dcnt2], DEC)

CrossRoads:
Serial.print (datary2, DEC)
vs
Serial.write( datary2 );

the command: Serial.print (datary2, DEC)
returns a error: call of overloaded 'print(int[32],int)' is ambiguous

if i put this command inside the loop, example: Serial.print( datary2*, DEC );*
it results in a wrong conversion, for example, the number 27 (in hex) appear 505613
thanks for your attention.

You need to NULL terminate the array, and then call strtoul() to convert the string to a numeric value. Then, you can print the numeric value in whatever base you want.

Hi, I am having difficulties to convert a HEX number

The values sent over the serial link are BINARY values in the range 0-255, using decimal notation to express them.

What range of values are you expecting?