Help - Converting gets string to integer 
Author Message
 Help - Converting gets string to integer

Hi,

Can't find this yet in FAQ's and on-line stuff so I thought
I'd try here while I'm looking ...

If I get a string from a file using gets, is there an easy way to
convert it to an integer? I could write a proc to do this, but
there might be some built in function ..... ?

Thanks,

Gary Cook.
Oxford, UK.



Sun, 30 Jun 2002 03:00:00 GMT  
 Help - Converting gets string to integer
Quote:

> If I get a string from a file using gets, is there an easy way to
> convert it to an integer? I could write a proc to do this, but
> there might be some built in function ..... ?

As they used to say: "Everything is a string" (it's slightly more
complicated these days under the hood). When your code needs an integer
(e.g. in expr or incr), it is automagically converted out of that
string. No need for explicit conversion, for decimals at least. For hex
strings, or getting the numeric value of a character, use scan.  
--
Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703
RC DT2, Siemens Electrocom, Buecklestr. 1-5, D-78467 Konstanz,Germany
-------------- http://purl.org/thecliff/tcl/wiki//Richard*Suchenwirth


Sun, 30 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need help:Convert Number String to Integers?

2. Help converting hex string to 16-bit signed two's complement integer

3. convert integer string to date string

4. Converting a number in a String character to an Integer

5. Convert 2D-Integer-Array to String

6. How do I convert integer to string array?

7. getting integer from string.

8. How can I convert string to integer?

9. Convert STRING to INTEGER

10. convert integer to string in linux

11. Using a library to convert integer to string

12. Converting string to float and integer

 

 
Powered by phpBB® Forum Software