Page 134 - C-Language
P. 134

/* common usages are concatenations of format strings */
         char* fmt = "%" PRId16; /* PRId16 macro since C99 */


        String literals, same as character constants, support different character sets.


         /* normal string literal, of type char[] */
         char* s1 = "abc";

         /* wide character string literal, of type wchar_t[] */
         wchar_t* s2 = L"abc";


        C11

         /* UTF-8 string literal, of type char[] */
         char* s3 = u8"abc";

         /* 16-bit wide string literal, of type char16_t[] */
         char16_t* s4 = u"abc";

         /* 32-bit wide string literal, of type char32_t[] */
         char32_t* s5 = U"abc";


        Fixed Width Integer Types (since C99)


        C99


        The header <stdint.h> provides several fixed-width integer type definitions. These types are
        optional and only provided if the platform has an integer type of the corresponding width, and if the
        corresponding signed type has a two's complement representation of negative values.

        See the remarks section for usage hints of fixed width types.


         /* commonly used types include */
         uint32_t u32 = 32; /* exactly 32-bits wide */

         uint8_t u8 = 255;  /* exactly 8-bits wide */

         int64_t i64 = -65  /* exactly 64 bit in two's complement representation */


        Floating Point Constants


        The C language has three mandatory real floating point types, float, double, and long double.


         float f = 0.314f;        /* suffix f or F denotes type float */
         double d = 0.314;        /* no suffix denotes double */
         long double ld = 0.314l; /* suffix l or L denotes long double */

         /* the different parts of a floating point definition are optional */
         double x = 1.; /* valid, fractional part is optional */
         double y = .1; /* valid, whole-number part is optional */

         /* they can also defined in scientific notation */
         double sd = 1.2e3; /* decimal fraction 1.2 is scaled by 10^3, that is 1200.0 */




        https://riptutorial.com/                                                                             110
   129   130   131   132   133   134   135   136   137   138   139