d01 ex04 boucle lecture ok
This commit is contained in:
61
d01/ex04/Makefile
Normal file
61
d01/ex04/Makefile
Normal file
@@ -0,0 +1,61 @@
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
# . name = value . name is case sensitive #
|
||||
# VARIABLES . or name = value \ . use VPATH only for .c #
|
||||
# . value . or .cpp #
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
NAME = sed
|
||||
|
||||
CC = clang++
|
||||
CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -std=c++98 -g3
|
||||
|
||||
VPATH = $(D_SRCS)
|
||||
|
||||
LIBS =
|
||||
|
||||
INCLUDES = -I$(D_HEADERS)
|
||||
|
||||
D_SRCS = .
|
||||
SRCS = main.cpp
|
||||
|
||||
D_HEADERS = .
|
||||
HEADERS =
|
||||
|
||||
D_OBJS = builds
|
||||
OBJS = $(SRCS:%.cpp=$(D_OBJS)/%.o)
|
||||
|
||||
RM_D_OBJS = rm -rf $(D_OBJS)
|
||||
ifeq "$(D_OBJS)" "."
|
||||
RM_D_OBJS =
|
||||
endif
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
# . target: prerequisites . $@ : target #
|
||||
# RULES . recipe . $< : 1st prerequisite #
|
||||
# . recipe . $^ : all prerequisites #
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(D_OBJS)/%.o: %.cpp | $(D_OBJS)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(D_OBJS):
|
||||
mkdir $@
|
||||
|
||||
$(OBJS): $(HEADERS:%=$(D_HEADERS)/%)
|
||||
|
||||
$(NAME): $(OBJS)
|
||||
$(CC) $(OBJS) -o $@ $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
|
||||
fclean: clean
|
||||
rm -f $(NAME)
|
||||
$(RM_D_OBJS)
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY : all clean fclean re bonus run valgrind
|
||||
24
d01/ex04/main.cpp
Normal file
24
d01/ex04/main.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
int main() {
|
||||
|
||||
std::ifstream file("test.txt");
|
||||
|
||||
// read words separated by whitespaces or newlines
|
||||
// std::string str;
|
||||
// while (file >> str)
|
||||
// std::cout << str << std::endl;
|
||||
|
||||
// skip whitespaces or newlines
|
||||
// char c;
|
||||
// while (file >> c)
|
||||
// std::cout << c << std::endl;
|
||||
|
||||
// seems good
|
||||
char c;
|
||||
while (file.get(c))
|
||||
std::cout << c;
|
||||
|
||||
}
|
||||
BIN
d01/ex04/sed
Executable file
BIN
d01/ex04/sed
Executable file
Binary file not shown.
27
d01/ex04/test.txt
Normal file
27
d01/ex04/test.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
No 1 more tears, my heart is dry
|
||||
I don't laugh and I don't cry
|
||||
I don't think about you all the time
|
||||
But when I do - I wonder why
|
||||
|
||||
You have to go out of my door
|
||||
And leave just like you did before
|
||||
I know I said that I was sure
|
||||
But rich men can't imagine poor.
|
||||
|
||||
One day baby, we'll be old
|
||||
Oh baby, we'll be old
|
||||
And think of all the stories that we could have told
|
||||
|
||||
Little me and little you
|
||||
Kept doing all the things they do
|
||||
They never really think it through
|
||||
Like I can never think you're true
|
||||
|
||||
Here I go again - the blame
|
||||
The guilt, the pain, the hurt, the shame
|
||||
The founding fathers of our plane
|
||||
That's stuck in heavy clouds of rain.
|
||||
|
||||
One day baby, we'll be old
|
||||
Oh baby, we'll be old
|
||||
And think of all the stories that we could have told
|
||||
Reference in New Issue
Block a user