Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Stack frame enum test
//gcc 5.4.0 #include <stdio.h> #include <string.h> typedef enum{ e_state_invalid, // <-- default value to prevent non-initialization e_state_boot, e_state_config, e_state_idle, e_state_running, e_state_last // <-- last for validation }e_system_state; void garbage_to_stack() { e_system_state garbage = e_state_last; printf("garbage at\t\t%p\r\n", &garbage); } void garbage_array_to_stack() { e_system_state garbage[1]; int test; memset(garbage, e_state_last, 1); printf("garbage array at\t%p\r\n", &garbage[0]); printf("test array at\t\t%p\r\n", &test, test); } void print_int() { int test; printf("test at\t\t\t%p\ttest = %x\r\n", &test, test); } void print_enum() { e_system_state current_state; printf("current_state at\t%p\tcurrent_state = %x\r\n", ¤t_state, current_state); } int main(void) { garbage_to_stack(); garbage_array_to_stack(); print_int(); print_enum(); print_int(); printf("e_state_invalid = %d\r\n", e_state_invalid); printf("e_state_boot = %d\r\n", e_state_boot); printf("e_state_config = %d\r\n", e_state_config); printf("e_state_idle = %d\r\n", e_state_idle); printf("e_state_running = %d\r\n", e_state_running); printf("e_state_last = %d\r\n", e_state_last); return 0; }
run
|
edit
|
history
|
help
0
HW4e5
Absolute valu
C_141204_ConcatenarCadenas
Project 5 v.08
Spring 2017 Project 2 v.03
ATM
B_14118_RestasSucesivas
lab2
1.8 Parallizing for loop
Type struct