Введение в язык программирования C99: Часть I
Опубликовано: 3 Марта, 2022
C99 is another name of ISO/IEC 9899:1999 standards specification for C that was adopted in 1999. This article mainly concentrates on the new features added in C99 by comparing with the C89 standard. In the development stage of the C99 standard, every element of the C language was re-examined, usage patterns were analyzed, and future demands were anticipated. C’s relationship with C++ provided a backdrop for the entire development process. The resulting C99 standard is a testimonial to the strengths of the original.
- Keywords added in C99:
- inline: C99 adds the keyword inline which is applicable to functions. If we write inline datatype function_name (param) to any function it means that we are specifying the compiler to optimize calls to that function i.e. the function’s code will be expanded inline rather than called.
Example:
// C program to demonstrate inline keyword
#include <stdio.h>
inline
int
maximum(
int
a,
int
b)
{
return
a > b ? a : b;
}
int
main()
{
int
x = 5, y = 10;
printf
(
"Maximum of %d and %d is %d"
,
x, y, maximum(x, y));
return
0;
}
Note: Some Compilers show undefined reference to maximum(). This inline feature is used rarely as a keyword.
The above program is equivalent to the following
#include <stdio.h>
int
main()
{
int
x = 5, y = 10;
printf
(
"Maximum of %d and %d is %d"
,
x, y, (x > y ? x : y));
return
0;
}
Output:Maximum of 5 and 10 is 10
РЕКОМЕНДУЕМЫЕ СТАТЬИ
- inline: C99 adds the keyword inline which is applicable to functions. If we write inline datatype function_name (param) to any function it means that we are specifying the compiler to optimize calls to that function i.e. the function’s code will be expanded inline rather than called.