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!

How can I convert a String into an Int?

Status
Not open for further replies.

solesilenzioso

Technical User
Apr 21, 2004
1
IT
I need to convert a char string into aa int.
Someone could help me?
Thanks
 
Do you mean you have a character representation of an integer? Like "4129"? Or do you have a character string whose bytes you want to represent as an integer?

In the former case, the string is already an integer as far as Tcl is concerned.
In the latter case, I think you want "binary scan". For example:
Code:
% set a xyz
xyz
% binary scan $a H6 b
1
% set b
78797a
%
The string, "xyz", is 3 bytes, or 6 hexadecimal characters.


Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top