Skip to content

Commit

Permalink
Add demos for lab01.
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
  • Loading branch information
gabrielmocanu committed Dec 24, 2021
1 parent 9f28545 commit 36a1b97
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
22 changes: 22 additions & 0 deletions laborator/content/reprezentare-numere/demo/pointers/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CC = gcc
CFLAGS = -Wall
LDFLAGS =

TARGET_EXEC = pointers

SRCS := $(shell find $(SRC_DIRS) -name "*.c")
OBJS := $(SRCS:.c=.o)

$(info OBJS is $(OBJS))
$(info SRCS is $(SRCS))

$(TARGET_EXEC): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS)

.o: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@

.PHONY: clean

clean:
$(RM) -r *.o $(TARGET_EXEC)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Author: Gabriel Mocanu <gabi.mocanu98@gmail.com>
*/


#include <stdio.h>

int main() {

int var;
int *p = (int *) 250;

printf("p : %p\n", p);
printf("p : %p\n", &p);
printf("var : %p\n", &var);

p = &var;
printf("p : %p\n", p);

p = p + 4;
printf("p : %p\n", p);

*p = &var;
printf("p : %p\n", &p);
printf("var : 0x%08x\n", var);

return 0;
}

0 comments on commit 36a1b97

Please sign in to comment.