Add test program for viewing stack.

This commit is contained in:
Ernie Pasveer
2024-10-06 09:55:22 -05:00
parent 1b2df9e5ed
commit 4817c28304
4 changed files with 34 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
hellostack
*.seer
+10
View File
@@ -0,0 +1,10 @@
.PHONY: all
all: hellostack
hellostack: hellostack.c
gcc -g -o hellostack hellostack.c
.PHONY: clean
clean:
rm -f hellostack
+3
View File
@@ -0,0 +1,3 @@
https://jvns.ca/blog/2021/05/17/how-to-look-at-the-stack-in-gdb/
+19
View File
@@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
char stack_string[10] = "stack";
int x = 10;
char *heap_string;
heap_string = malloc(50);
printf("Enter a string for the stack: ");
gets(stack_string);
printf("Enter a string for the heap: ");
gets(heap_string);
printf("Stack string is: %s\n", stack_string);
printf("Heap string is: %s\n", heap_string);
printf("x is: %d\n", x);
}