Skip to content
Snippets Groups Projects
Commit ef8cbfd9 authored by iliya's avatar iliya
Browse files

ex2 finished, feat mes beaux commit @ JAD

parent 4445dddd
Branches
Tags
No related merge requests found
*.o
prog
CC := clang
CFLAGS := -g -pedantic -Wall -Wextra -std=c2x
LDFLAGS := -fsanitize=address -fsanitize=leak -fsanitize=undefined -lm
TARGET := prog
all: $(TARGET)
$(TARGET): prog.o
@printf "=================== Building executable ===================\n"
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
@printf "\n"
%.o: %.c
@printf "================== Building object files ==================\n"
$(CC) $(CFLAGS) -c $<
@printf "\n"
clean:
rm -f *.o $(TARGET)
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
char *str;
char replacing_space;
} str_space_replaced;
void replace_space(str_space_replaced *str) {
for (size_t i = 0; i < strlen(str->str); i++) {
fprintf(stderr, "%c\n", str->str[i]);
if (str->str[i] == ' ') {
str->str[i] = str->replacing_space;
}
}
}
int main(void) {
char my_str[] = "Lorem ipsum dolor imet";
str_space_replaced str = {
.str = my_str,
.replacing_space = 'A',
};
replace_space(&str);
fprintf(stdout, "New string: %s\n", str.str);
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment