Skip to main content

C99 Features

                             Other


C99 Features

C programming is developed and standardized by ANSI and ISO and is popular for its powerful, flexible, and elegant language. Because of its suitability for both systems based as well as application based programming it has become an industry standard, general purpose language today. The standardization committee which is working on C are trying to check each element of the language critically and decided that a change or enhancement is necessary in order to continue its legacy and popularity. So, new features were included with a new version – C99. It is recognized as one of the advanced topics of C. In this chapter, you will learn about the features that are available in C99 standard but not in its previous version.

What is C99?

The C99, previously known as the C9X, is an informal name for ISO/IEC 9899:1999 of C programming standard. It is the enhanced and newer version of C90 with added features for the language and the standard library and hence makes use of better implementation of the available computer hardware such as the IEEE arithmetic and compiler technology.

Important Features of C99

The C99 standard introduces several new language features. These new features include:
  • Some features are like extensions to C90 offered by GNU compiler such as macros with variable number of arguments.
  • C99 allows the use of complex numbers and designated initializers.
  • Restricted pointers are also added in C99.
  • There are some new keywords and identifiers.
  • New comment techniques
  • Inline functions
  • Variable length array
  • Flexible array members
  • New header files were included
  • Addition of Compound Literals

History of C99

As the official standard for C language was produced by ANSI (American national Standard Institute) in the year 1989, and then became an international standard in the year 1990, the specification of the C language remain relatively static for some time, with the evolving C++. The standard underwent further revision in the late 1990s, leading to the publication of ISO/IEC 9899:1999 in the year 1999, which was adopted as an ANSI standard in May 2000. So the C language defined by that version of the standard is commonly referred to as “C99”.
The C99 standard incorporates new enhancements and included advanced features that are desirable for any modern computer language. Some of the features are borrowed from C++ while others are modification of few constructs.

New C99 Keywords

ANSI C has defined 32 keywords in C. C99 has added five more keyword to that old group of keywords. Addition of these new keywords is perhaps the most significant feature of C99. The new 5 keyword are:

_Bool

_Bool: as the name suggest is of type integer which is used to declare Boolean type variables i.e. it can store only zeros (0s) and ones (1s). This is a new data type of C introduced by C99.

_Complex

_Complex: It is used to declare complex floating type variables to store mathematical complex numbers. This is a new data type that is included in C99. They are declared as:
Syntax:
float _Complex variable_name;
double _Complex variable_name;
Example: float _Complex z = l + 2*J;
or it can also be declared as:
Syntax:
float complex z = l + 2*J;
z = l/z;
if the header file <complex.h> is included at the beginning of the program.

_Imaginary

_Imaginary: It is used to declare imaginary floating type variables store mathematical imaginary numbers. This is also a new data type included by C99. It is declared like that of _Complex –
Syntax:
double _Imaginary variable_name;
float _Imaginary variable_name;

inline

inline: The objective of the inline specifier is to supply a hint for the compiler to perform optimizations, such as function inlining, that require the definition of a function to be visible at the call site. The compilers can ignore the presence or absence of the inline specifier for the purpose of optimization.
Example:
static int g;

inline void k(void)
{
static int s = 1;
int x = g;
/*The above line is an error because the non-static inline function is accessing the static variable*/
}

restrict

restrict: The “restrict” keyword has been introduced by C99 as a type qualifier that can be used only to pointers. A pointer when qualified with the keyword ‘restricted’ is referred to as restricted pointer.Restricted pointers are declared as follows:
Example:
int *restrict pt;
void *restrict ptr1;
When a pointer is declared as restricted, it becomes the only means to access the object it points to.

Declaration of variables

It is legal to declare variables it at any point of the program within the curly braces of main() function.
Example:
#include<stdio.h>
#include <complex.h>

main
()
{
int g;
g
= 600;
. . .
. . .
int k; // Legal in C99
k
= 200;
. . .
}

Variable Array length

In ANSI C, array dimension must have to be declared. But C99 permits declaration of array dimensions using integer variables or any valid integer expressions. This is called Variable length array.
This is how the variable length arrays are declared:
Example:
#include<stdio.h>
main
()
{
int x, y;
scanf
("%d %d", &x, &y);
float matrix [x][y]; /*Variable Length array*/
. . .
. . .
}

Comments

For Programs Click Here

Popular posts from this blog

Syllabus

Syllabus  C Programming Tutorials C Tutorial C Introduction History of C Programming Language C Installation C Program Structure C Input and Output (I/O) C Format Specifiers Declaration & Assignments C Tokens C Identifiers C Keywords C Constants C Operators C Data Types C Variables C Preprocessors C Type Casting C Custom Header File Flow Control C Decision Making C if Statements C if-else Statements C Nested if-else Statements C else-if Statements C goto Statement C switch Statements C Loops C while loops C do while loops C for loops Functions C Functions C Function Arguments C Library Functions C Variable Scope Arrays & Strings C Arrays C Strings Pointers C Pointers C Dynamic Memory Allocation Structure & Union C Structures C Unions File I/O C File Handling C fopen C fclose C getc C putc C getw C putw C fprintf C fscanf C fgets C fputs C feof                                     ...

Syllabus

Python Tutorials Python Tutorial Python Overview Python Installation Basics of Python Programming Python Operators Python Keywords Python Numbers Python Strings Python Data Types Python Variables Python Lists Python Tuples Python Date and Time Python Decision Making Python Loops Python File Handling Python Dictionaries Python Functions Python Modules Python Exceptions Handling Python Object Oriented Inheritance in Python Python Regular Expressions Python Networking Programming Python Multithreaded Programming Python CGI Programming Python Database Connection Python Metaprogramming Python Data Processing And Encoding Python GUI Programming

C++ Data Abstraction

C++ Data Abstraction Object oriented programming offers various features to write programs with various concepts that help to minimize problems and increase flexibility in program. One of the features of object oriented programming is Data abstraction. In this chapter you will learn about how the concept data abstraction is carried out within the C++ program. What is Data abstraction? Data abstraction allows a program to ignore the details of how a data type is represented. Abstraction (derived from a Latin word  abs , meaning away from and  trahere , meaning to draw) refers to the act of representing essential features without including the background details or explanations. C++ classes use the technique of abstraction and are defined as a list of abstract attributes such as width, cost, size etc and functions to operate on these attributes. They put in a nutshell all the essential properties of an object that are required to be created. The attributes are therefore called...