...

View Full Version : Converting from char to int



Lippy
02-09-2005, 02:33 PM
is there a function or something that converts a character number value like '42' to a decimal 42...

thanks for the help...
Lippy

KeZZeR
02-09-2005, 02:45 PM
yeh, toInt() ;)

Koobi
02-09-2005, 02:49 PM
In what language is this?

You can also type cast, just to let you know.


Example:


myString = (int) myString;

KeZZeR
02-09-2005, 04:13 PM
In what language is this?

You can also type cast, just to let you know.


Example:


myString = (int) myString;


That depends on what language as well. In Java, if you do that, it wouldn't work as myString is most probably of type String, so casting it to an int and shoving it back in a variable with a data type of String wouldn't work.

Koobi
02-09-2005, 04:23 PM
That depends on what language as well. In Java, if you do that, it wouldn't work as myString is most probably of type String, so casting it to an int and shoving it back in a variable with a data type of String wouldn't work.


Yep, thanks for pointing that out :)
I neglected to mention that the method I posted would work in C++

Dr. Evil
02-09-2005, 05:52 PM
In C you can use the atoi() function, or create your own.

Lippy
02-09-2005, 06:20 PM
Thanks, that atoi function works great...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum