Open In App
Related Articles

GFact | C standard C99 allows inline functions and variable-length-arrays

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
The C standard C99 allows inline functions and variable-length-arrays. So following functions are valid in C99 compliant compilers. Example for inline functions
inline int max(int a, int b)
{
  if (a > b)
    return a;
  else
    return b;
  
a = max (x, y); 
/*
  This is now equivalent to 
  if (x > y)
    a = x;
  else
    a = y;
*/

                    
Example for variable length arrays
float read_and_process(int n)
{
    float   vals[n];
   
    for (int i = 0; i < n; i++)
        vals[i] = read_val();
    return process(vals, n);
}

                    
References: http://en.wikipedia.org/wiki/C99 http://en.wikipedia.org/wiki/Variable-length_array http://en.wikipedia.org/wiki/Inline_function

Last Updated : 18 Oct, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads