📜  C99编程语言简介:第三部分

📅  最后修改于: 2021-05-25 20:42:23             🧑  作者: Mango

在阅读本文之前,请先阅读C99编程语言简介(第一部分)和C99编程语言简介(第二部分)。

  1. 库功能的补充: C99提供了下面列出的一些其他库功能。
    Library Function Usage
    complex.h complex.h supports complex arithmetic
    fenv.h fenv.h gives access to floating point tags and floating point environments.
    inttypes.h inttypes.h gives support to handle long numbers (larger width numbers).
    It defines a standard, portable integer names
    iso646.h iso646.h defines macros corresponds to operators like && and ^
    stdbool.h stdbool.h supports boolean data types.
    It gives macros like bool, true and false.
    stdint.h stdint.h is included in inttypes.h header file.
    It gives standard, portable set of integer names.
    tgmath.h tgmath.h defines type-generic floating-point macors
    wchar.h wchar.h supports multibyte and wide character functions.
    wctype.h wctype.h supports multibyte and wide character classification functions.
  2. 格式说明符的添加:在C99 Standard中,对printf()scanf()函数进行了修改,使其能够处理long longunsigned long long修饰符。 long long int的格式说明符为ll,而unsigned long long int的格式说明符为ul。

    下面的示例程序演示了long long和unsigned long long值的用法。

    #include
      
    int main()
    {
        long long int a=1121231456;
        unsigned long long int b=1124154632;
        printf("Long Number: %lld and"
    " Unsigned long: %llu",
     a, b);
    }
    
  3. __func__标识符:
    C99添加__func__标识符,该标识符返回作为字符串调用的函数的名称。简单来说,如果在fun1()函数调用__func__,它将返回字符串fun1
  4. 隐式int声明:
    在C89标准中,我们不需要在函数中显式声明整数返回类型,即,如果我们声明function_name(parameters),则编译器将假定整数为默认返回类型。在C99中,不再支持所有隐式函数声明。一些编译器将引发错误,而某些编译器将显示与警告相同的错误。 GCC编译器将其显示为警告。
  5. 无效返回类型:
    在C89 Standard中,我们可以省略函数的返回值。如果我们编写int fun1()并在不指定返回值的情况下执行它,则编译器将采用默认的返回值自动执行。该值可以是0或垃圾值。但是在C99中,如果我们在编写int fun1()时没有返回语句,则编译器会将其视为错误。
  6. 扩展整数类型: C99标准对整数类型进行了多种扩展。
    Extended Type Meaning
    int16_t Integer has exactly 16 bits
    int_least16_t Integer has at least 16 bits.
    int_fast32_t Fastest Integer types that has at least 32 bits.
    intmax_t Holds the Largest Integer Type
    uintmax_t Holds the Largest unsigned Integer Type

    这些通常很少使用。

这些是一些重大更改,包括添加,更改和删除C89中的功能以获得C99 Standard。

想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。