Created
April 20, 2014 17:05
-
-
Save robsbots/11119276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************** | |
* odd_func.c | |
* | |
* Strange function definition test | |
* | |
* Can you define one function inside another and have it compile ? | |
* Apparently you can. | |
* We can have local functions....... | |
* Neither of these local function can be called from outside their scope. | |
* | |
* compile with 'cc odd_func.c -o odd_func' | |
***************************************************************************/ | |
#include <stdio.h> | |
// A normal function predefined | |
void a_func(void); | |
// Main as usual | |
int main(int argc, char* argv[]) | |
{ | |
// Standard etc | |
printf("Hello world\n"); | |
// Define a new "local" function | |
void test1(void) | |
{ | |
printf("Tester function\n"); | |
} | |
// Call that function defined above | |
test1(); | |
// Call the normal function | |
a_func(); | |
// return with no error | |
return 0; | |
} | |
void a_func(void) | |
{ | |
// Just something to do | |
printf("a Function\n"); | |
//define another local function | |
void test1(void) | |
{ | |
printf("Another Tester function\n"); | |
} | |
// Call this new local function | |
test1(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment