Computer Science Canada change string to int |
Author: | appling [ Thu Feb 05, 2004 4:13 pm ] |
Post subject: | change string to int |
what should i do if i have a string varable with 249.23 stored in it, and i want to times that number with 1.07??? |
Author: | recneps [ Thu Feb 05, 2004 4:28 pm ] | ||
Post subject: | |||
use strreal (or streal?) eg
the strreal changes str to real, then multiplies by 1.07, and then is rounded off so it can be an int. if you dont want int, just real, make var1 a real var and get rid of round() |
Author: | appling [ Thu Feb 05, 2004 4:35 pm ] |
Post subject: | |
i need to input the price from a txt file and calculate the gst.for this i can only declare the variable as string. |
Author: | Martin [ Thu Feb 05, 2004 4:45 pm ] | ||||||
Post subject: | |||||||
Suppose that you have something like this:
strint converts a string to an integer. Take this case however:
This program would crash, because s can't be converted into an integer. To check to see if a variable can be converted to an integer, use strintok(string). If it can be converted, it will return true, if it can't, it will return false.
|
Author: | appling [ Thu Feb 05, 2004 4:55 pm ] |
Post subject: | |
i try that but turing said -- illegal character in string passed to "strint" |
Author: | Cervantes [ Thu Feb 05, 2004 5:04 pm ] |
Post subject: | |
darknesses code works fine for me. what version of Turing are you using? I'm on 4.0.5. also are you using the last section of code that darkness posted? if so, post your code and we can have a looksie. |
Author: | appling [ Thu Feb 05, 2004 6:10 pm ] | ||||
Post subject: | |||||
i am using 4.0.4c this is my code
this is the iii.txt
|
Author: | Andy [ Thu Feb 05, 2004 7:36 pm ] |
Post subject: | |
ummm dude, thats not a frigging int, do u not read? you have to use strreal |
Author: | appling [ Thu Feb 05, 2004 8:39 pm ] |
Post subject: | |
thanks i get that. this really is a good place |