1.0.0 2026-01-26 10:42 2026-02-02 10:42 submit-* (limit: 3 per week) archi-* (limit: 2 per hour) prog-102-p-03-2030-firstname.lastname
├── Digby_Real_Estate
│ ├── Fundamentals
│ │ ├── count.c
│ │ ├── most_frequent.c
│ │ ├── my_factor.c
│ │ ├── my_strapp.c
│ │ ├── my_weirddup.c
│ │ ├── replace.c
│ │ └── trap_sweeper.c
│ └── Proficiencies
│ ├── better_replace.c
│ ├── nearest_target.c
│ └── split_words.c
├── .gitignore
└── README
firstname.lastname with your login. .gitignore file is mandatory. Tests folder. .gitignore file:*.a
*.lib
*.o
*.obj
*.out
.idea/
*~
*.DotSettings.user
malloc(3) and all functions associated a lot.<stdlib.h> library, we encourage you to look at their man page using the man 3 malloc command.Fundamentals/count.c count which takes an int n, your goal is to allocate an array that fits the integers from 1 to n and return it.NULL.n is less than 1, you must return NULL.int *count(int n);
count(0); // NULL
count(1); // {1}
count(6); // {1, 2, 3, 4, 5, 6}
count(7); // {1, 2, 3, 4, 5, 6, 7}
Fundamentals/my_weirddup.c my_weirddup which takes the string src, frees it and returns a copy of that string except that, for each letter of the string, you'll have to replace it with the next letter. Don't forget to come back to the first letter when you need to duplicate a 'z'.NULL.src is NULL you must return NULL.char *my_weirddup(char *src);
my_weirddup("a"); // "b"
my_weirddup("abcxyz"); // "bcdyza"
my_weirddup("ABC 123"); // "BCD 123"
<default string> ; <duplicate string>\n, using the function you just created.strdup(3) to pass the arguments into your functions as arguments aren’t malloc-allocated.strdup(3) is a functions of the <string.h> library. This function returns a malloc-allocated copy of the string passed as an argument to the function.man 3 strdup command).$ ./my_weirddup a abcxyz ABC123
a ; b
abcxyz ; bcdyza
ABC123 ; BCD123
Fundamentals/my_strapp.c realloc function.my_strapp function takes two arguments, the src which is the string that we want to append and the dest pointer which points to the string where we want to append.src is NULL or dest is NULL. If the string pointed by dest is NULL, you can create the string with your own hands.void my_strapp(char *src, char **dest);
char *src = strdup("World!");
char *dest = strdup("Hello, ");
char **dest_ptr = &dest;
my_strapp(src, dest_ptr); // Hello, World!
free(src);
free(dest);
Fundamentals/my_factor.c my_factor that returns an array containing the factors of the number n, excluding 1 and n itself.n is negative or equal to 0, you must return NULL.'\0' character ? We will do the same, be sure that your array finishes with the number 0.NULL.int *my_factor(int n);
Factors :
[1st argument] : [its factors separated by spaces]
[2nd argument] : [its factors separated by spaces aswell]
.
.
.
int argc and char *argv[] as arguments for your main function as so :int main(int argc, char *argv[])argc as the number of arguments, and argv the array containing the strings of each argument.atoi(3) function to help you in this exercise. The manual is accessible with man 3 atoi.int main (int argc, char *argv[]);
$ ./factors 10 42069 -1 0
Factors :
10 : 2 5
42069 : 3 37 111 379 1137 14023
-1 : NULL
0 : NULL
$ echo $? # This prints the return code of last command in the terminal
0
$ ./factors
$ echo $?
0
malloc, realloc or calloc.Fundamentals/replace.c str and another string sub. The goal of the function is to replace all asterisks (*) in the string str by the string sub. You must then return a new pointer to the result string.str is NULL or if the allocation fails, you must return NULL. But if sub is NULL, it is like working with "" (you should replace the asterisks by an empty string).char *replace(char *str, char *sub);
replace("Hello *", "World!"); // Hello World!
replace("*H*e*l*l*o*", "BIM"); // BIMHBIMeBIMlBIMlBIMoBIM
Fundamentals/most_frequent.c most_frequent that takes in parameters a single string and returns the most frequent character of that string.NULL, return \0.\0.char most_frequent(const char *str);
most_frequent("WRYYYY!1!"); // 'Y'
most_frequent("ORA ORA ORA!"); // 'O'
most_frequent("hello warudo!"); // 'l'
most_frequent("oRA ora oRa?"); // 'o'
malloc or calloc.Fundamentals/trap_sweeper.c trap_sweeper that will take the matrix garden as argument and will return another matrix.#' symbol.NULL.0.NULL.rows of your matrix times the size of a pointer, in our case, an int * (even though all data pointers share the same size). int **trap_sweeper(char **mat, int rows, int cols);
#include <stdio.h>
int main()
{
char *mat1[] = {
"OOO#O", // 1 1 2 -1 2
"#OO#O", // -1 3 4 -1 2
"O##OO", // 2 -1 -1 3 2
"OOOO#" // 1 2 2 2 -1
};
int **res = trap_sweeper(mat1, 4, 5);
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 5; ++j)
printf("%d ", res[i][j]);
printf("\n");
}
for (int i = 0; i < 4; ++i)
free(res[i]);
free(res);
}
1 1 2 -1 2
-1 3 4 -1 2
2 -1 -1 3 2
1 2 2 2 -1
Proficiencies/split_words.c split_words that will take as argument a string and will return an array of strings containing the different words of the first one, this array must be NULL terminated.NULL.isspace(3) function.char **split_words(char *str);
split_words("Hello World!"); // "Hello", "World!", NULL
split_words("Hello World! I am here !"); // "Hello", "World!", "I", "am", "here", "!", NULL
Proficiencies/better_replace.c replace function, except that instead of replacing each asterisk, you will take a third argument (the to_replace string) and replace every occurence of this string in the str string by the sub string.str is NULL or if malloc fails, you must return NULL.to_replace is NULL, you just return a duplicate of str.sub is NULL, it is the same thing as it being an empty string.char *better_replace(char *str, char *sub, char *to_replace);
better_replace("Hello You!", "World", "You"); // Hello World!
better_replace("The name of my dog is dog", "cat", "dog"); // The name of my cat is cat
Proficiencies/nearest_target.c nearest_target function that takes a matrix of characters and a character target. Your function will return a matrix of the same size as the one taken as a parameter but instead of the characters we expect you to put a int that will represent the distance between that cell and the cell containing the nearest target.NULL.NULL.must fill all the cells with -1.int **nearest_target(char **mat, int rows, int cols, char target);
char *mat1[] = {
"ab",
"aa"
};
char *mat2[] = {
"aba",
"aaa",
"baa"
};
int **res1 = nearest_target(mat1, 2, 2, 'b');
int **res2 = nearest_target(mat2, 3, 3, 'b');
// res1 = {
// { 1,0 },
// { 2,1 }
// }
// res2 = {
// { 1,0,1 },
// { 1,1,2 },
// { 0,1,2 }
// }