
gcc supports Nested functions as the following example shows:
void isort (int arr[], int len) {
//shift_element() is the nested function
void shift_element (int i) {
int ivalue;
for (ivalue=arr[i]; i && arr[i-1] > ivalue; i--) {
arr[i] = arr[i-1];
}
arr[i] = ivalue;
}
int i;
for (i=1; i < len; i++) {
if (arr[i] < arr[i-1]) {
shift_element(i);
}
}
}
gcc also provides many other useful features which can NOT be found in ANSI standard c. For more information, refer to Extensions to the C Language Family.




近期评论