What is strintok
Author |
Message |
xSonu
|
Posted: Wed Jan 20, 2010 10:01 pm Post subject: What is strintok |
|
|
I`m a bit confused. I know strintok is a error trap but what does it really mean.
Yea yea, i know you people are probably saying go check the reference manual or its on the site.
But the definitions on the site and manual, i dont get them
i mean converting string to integer
its not getting to me, could someone explain it in a more simpler way. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Zren
![](http://compsci.ca/v3/uploads/user_avatars/1110053965512db6185954b.png)
|
Posted: Wed Jan 20, 2010 10:27 pm Post subject: RE:What is strintok |
|
|
If string can convert to an integer then,
X is the integer value of Str.
Basically it checks the string if it's compatible as an Integer, and returns true or false. If it's false, then you skip the conversion and immenent failure. |
|
|
|
|
![](images/spacer.gif) |
TerranceN
|
Posted: Wed Jan 20, 2010 10:31 pm Post subject: Re: What is strintok |
|
|
strint changes a string to an integer, but if the string has something other than letters, your program will crash. This is where strintok becomes useful.
stringok checks if you can convert a string to an integer, so:
but
so if you use this in an if statement with strint, you can prevent the error, and even say what to do if there would have been an error
Turing: | var num : int := 0
var str : string := "5"
if strintok(str ) then
num := strint(str )
else
% handle error
end if
put num |
Hope that helps |
|
|
|
|
![](images/spacer.gif) |
|
|