c / beginner
Snippet
Explicit Type Casting
Type casting allows you to manually convert a value from one data type to another, such as truncating a float to an int.
snippet.c
1
2
float pi = 3.14159f;int simplePi = (int)pi;
Breakdown
1
(int)pi
Forces the floating-point value to be treated as an integer, removing decimals.