Skip to content

Instantly share code, notes, and snippets.

@pavly-gerges
Created February 14, 2023 22:33
Show Gist options
  • Save pavly-gerges/e68e4d4f06cc33c90237969f72ad40d1 to your computer and use it in GitHub Desktop.
Save pavly-gerges/e68e4d4f06cc33c90237969f72ad40d1 to your computer and use it in GitHub Desktop.
An example shows a function definition inside another function demonstrating local scopes effect on function definition
#include <stdio.h>
static inline void call_stack() {
void inside_block() {
printf("inside block");
}
inside_block();
}
int main() {
call_stack();
return 0;
}
@pavly-gerges
Copy link
Author

Those are other shapes of local function definitions:

#include <stdio.h>

void stack() {
    Block:{
        void inside_block() {
            printf("inside block");
        }
        inside_block();
    }
}

int main() {
    stack();
    return 0;
}

Highly discouraged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment