Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sprintf

Status
Not open for further replies.

selimsl

Programmer
Aug 15, 2005
62
TR
Code:
char asciihex[5];
short int datax=10;
sprintf(asciihex,"%4X",datax);
As you know, result of this code is : " A"

Is there any function to reverse this operation.I mean,

Code:
asciihex[5]="   A";
datax=function(asciihex);

result is :datax=10

Thanks in advice...



 
Code:
char asciihex[5]="   A";
short int datax;
sscanf(asciihex,"%hX",&datax);

--
 
Or use strtol() from stdlib.h:
Code:
datax = strtol(asciihex,0,16);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top