- 1

How to get a number from a string input

I don't know if this is entirely possible, but if it is, how would I make it so that a certain string input gives a variable (int, float, etc) a specific number value. for example, if you were to put a certain word or letters in the input, say like "abc" for the value of the string variable, and then a different variable that was a float or integer was given a number value for the rest of the code. mind you, this variable would be added and multiplied and whatnot with other number variables

5th May 2017, 3:56 PM
Brian Bauch
Brian Bauch - avatar
6 Antworten
+ 4
Where is your code? You don't have any public made in your profile ^^ Anyway, your description isn't clear: are you trying to convert a string value to an integer or floating point one? And what's the language you're interrested for the answer?
5th May 2017, 4:04 PM
visph
visph - avatar
+ 3
So, edit your question to at least ad 'c++' tag if you don't want to get answer in plenty of language ;P
5th May 2017, 4:07 PM
visph
visph - avatar
+ 3
treat your string as an array of characters. So now, using an array, how will you display your number??
6th May 2017, 5:21 AM
Krishneel Nair
Krishneel Nair - avatar
+ 1
Alright I'll get the code, and I'm pretty much trying to convert a string to a number value and it's c++
5th May 2017, 4:05 PM
Brian Bauch
Brian Bauch - avatar
0
I've tried experimenting but the code always alters the number or something because I don't get the right result, but I do get a result
5th May 2017, 3:57 PM
Brian Bauch
Brian Bauch - avatar
0
soooo, I must've done something wrong last time because I re entered the code and it's all good now. thank you anyways, and I'll make sure I post the code if anything else goes wrong
5th May 2017, 4:20 PM
Brian Bauch
Brian Bauch - avatar