·  C – Syntax – Variables – char

 

- Info:

  - This tutorial shows how to create char and convert it to other Primitive Types.

 

- Procedure:

  - Create C Console Application Test.c.

 

    Test.c

    #include <stdio.h>

   

    int main () {

   

      /*CREATE.------------------------------------------------------------------------*/

      char     value    = 'A';

               value    =  65;    /*Decimal     ASCII value.*/

               value    = 0101;   /*Octal       ASCII value.*/

               value    = 0x41;   /*Hexadecimal ASCII value.*/

   

      /*CONVERT.-----------------------------------------------------------------------*/

      {

        short  convert1 = value;

        int    convert2 = value;

        long   convert3 = value;

        float  convert4 = value;

        double convert5 = value;

        printf("%c %i %f\n", convert1, convert2, convert5);

      }

   

      /*DISPLAY.-----------------------------------------------------------------------*/

      printf("%c %i", value, value);

   

      return 0;

    }