Variable Casting
This lesson will let you know how variables can be converted from one type to another via casting.
We'll cover the following
What is Casting?
It is often important to be able to convert between different types of data.
For example, the user may request a double
precision value from your program, but your program stores them as floats
. The requires a conversion method between types. This conversion is accomplished via casting.
The syntax for casting is as follows:
(type)name
Where type is the type to convert to, and name is the name of the variable to convert.
Example
Get hands-on with 1400+ tech skills courses.