Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/* Low-level i/o sample */
typedef struct Hdr { int x, y; } *Phdr;
char buff[100];
Phdr p;
...
if (fread(buff,1,100,f) >= sizeof(struct Hdr))
{
p = (Phdr)buff;
/* as usually, do nothing (char* bits == p bits)
* char[] implicitly casted to char* then your cast...
* Now the compiler knows that you know what to do...
*/
...
/* Another case (may be you have specifications;) */
int n = 123;
...
printf("%f\n",(double)n); /* as usually, the compiler emits implicit RTL call */
A cast is an operator that performs a conversion. The compiler generates any code necessary to perform the conversion.i wanted to understand how type casting is handled at the compiler level. meaning what provisions are made and how the variable casted is treated by the compiler ?
Converting from floating point to integer is one example. The compiler might generate code the calls a function ("__ftol" perhaps) to perform the conversion.C99 said:Preceding an expression by a parenthesized type name converts the value of the expression to the named type. This construction is called a cast.