cpp01...
This commit is contained in:
26
ex02/Makefile
Normal file
26
ex02/Makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
NAME=memory
|
||||
|
||||
SRCS=main.cpp
|
||||
|
||||
OBJS=$(SRCS:.cpp=.o)
|
||||
|
||||
CC=g++
|
||||
CFLAGS=-Wall -Wextra -Werror -std=c++98
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(OBJS) -o $(NAME)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
|
||||
fclean: clean
|
||||
rm -f $(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY: all clean fclean re
|
||||
43
ex02/main.cpp
Normal file
43
ex02/main.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/06 01:58:01 by aortigos #+# #+# */
|
||||
/* Updated: 2025/09/06 02:18:56 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string str = "Hola";
|
||||
std::string *ptr = &str;
|
||||
std::string &ref = str;
|
||||
|
||||
std::cout << "Imprimiendo direcciones de memoria...";
|
||||
std::cout << std::endl << std::endl;
|
||||
|
||||
// Imprimimos las direcciones de memoria
|
||||
std::cout << &str << std::endl;
|
||||
std::cout << ptr << std::endl;
|
||||
std::cout << &ref << std::endl;
|
||||
|
||||
std::cout << std::endl << std::endl;
|
||||
|
||||
|
||||
|
||||
// Imprimimos los valores
|
||||
|
||||
std::cout << "Imprimiendo los valores de las variables...";
|
||||
std::cout << std::endl << std::endl;
|
||||
|
||||
std::cout << str << std::endl;
|
||||
std::cout << *ptr << std::endl;
|
||||
std::cout << ref << std::endl;
|
||||
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user