Type Explicit Conversions - C Data Type

C examples for Data Type:Type Cast

Introduction

An explicit cast is done by adding the target data type in parentheses in front of the expression.

Demo Code

#include <stdio.h>
int main(void) {

    int i = (int)10.5; /* double demoted to int */
    char c = (char)i;  /* int demoted to char */
    /*from   w w w .  ja  va  2s  .c  o  m*/
    printf("%c",c);
}

Related Tutorials