The Piscine was good but the time has passed. This series of exercises will help you revisit all the basics you’ve learned during the Piscine. Functions, loops, pointers, structures—let’s revisit together the syntactic and semantic bases of C.
Version: 1.2
- General Rules
- Exercise 00: Oh yeah, mooore...
- Exercise 01: Z
- Exercise 02: clean
- Exercise 03: find_sh
- Exercise 04: MAC
- Exercise 05: Can you create it?
- Exercise 06: ft_print_alphabet
- Exercise 07: ft_print_numbers
- Exercise 08: ft_is_negative
- Exercise 09: ft_ft
- Exercise 10: ft_swap
- Exercise 11: ft_div_mod
- Exercise 12: ft_iterative_factorial
- Exercise 13: ft_recursive_factorial
- Exercise 14: ft_sqrt
- Exercise 15: ft_putstr
- Exercise 16: ft_strlen
- Exercise 17: ft_strcmp
- Exercise 18: ft_print_params
- Exercise 19: ft_sort_params
- Exercise 20: ft_strdup
- Exercise 21: ft_range
- Exercise 22: ft_abs.h
- Exercise 23: ft_point.h
- Exercise 24: Makefile
- Exercise 25: ft_foreach
- Exercise 26: ft_count_if
- Exercise 27: display_file
- Submission and Peer-Evaluation
- Only the official page is your reference.
- Ensure correct permissions for files and directories.
- Follow proper turn-in procedures.
- All exercises will be graded by Moulinette, a strict and automated program.
- Shell exercises must be executable with
/bin/sh
. - Submit only the specified files.
- Respect the Norm: your code must pass
norminette
. - Forbidden functions are considered cheating.
- Submit
main()
only when asked. - Compilation flags:
-Wall -Wextra -Werror
. - If your program doesn’t compile, you’ll get a 0.
Create specific files and directories to match a given output structure. Use tar -cf exo.tar *
to submit.
Create a file z
that returns "Z\n" when used with cat
.
Write a single command in clean
to find and delete all files ending with ~
or wrapped with #
in the current and subdirectories.
Write a script that finds all files ending with .sh
and displays their names without the extension.
Write a command to display your machine’s MAC addresses.
Create a file containing only "42", and NOTHING else. Its name will be a specific sequence of characters.
Create a function that displays the alphabet in lowercase, on a single line, in ascending order.
Create a function that displays all digits, on a single line, in ascending order.
Create a function that displays 'N' or 'P' depending on the integer's sign entered as a parameter.
Create a function that takes a pointer to int as a parameter and sets the value "42" to that int.
Create a function that swaps the value of two integers whose addresses are entered as parameters.
Create a function ft_div_mod
that divides two integers and stores the quotient and remainder in respective pointers.
Create an iterative function that returns the factorial of a number.
Create a recursive function that returns the factorial of a number.
Create a function that returns the square root of a number (if it exists), or 0 if it’s irrational.
Create a function that displays a string of characters on the standard output.
Reproduce the behavior of the strlen
function.
Reproduce the behavior of the strcmp
function.
Create a program that displays its given arguments.
Create a program that displays its given arguments sorted by ASCII order.
Turn-in directory: ex20/
Files to turn in: ft_strdup.c
Allowed functions: malloc
Reproduce the behavior of the strdup
function.
Turn-in directory: ex21/
Files to turn in: ft_range.c
Allowed functions: malloc
Create a function ft_range
that returns an array of integers containing all values between min
(inclusive) and max
(exclusive). If min
is greater or equal to max
, return a null pointer.
Turn-in directory: ex22/
Files to turn in: ft_abs.h
Allowed functions: None
Create a macro ABS
which replaces its argument by its absolute value:
#define ABS(Value)
Turn-in directory: ex23/
Files to turn in: ft_point.h
Allowed functions: None
Create a header file ft_point.h
that defines a t_point
structure with x
and y
as integer fields. Write a function set_point
to assign values to a t_point
.
Turn-in directory: ex24/
Files to turn in: Makefile
Allowed functions: None
Create a Makefile
to compile libft.a
using source files from the srcs
directory and headers from the includes
directory. Include rules for clean
, fclean
, re
, and all
.
Turn-in directory: ex25/
Files to turn in: ft_foreach.c
Allowed functions: None
Create a function ft_foreach
which applies a given function to all elements of an integer array.
Turn-in directory: ex26/
Files to turn in: ft_count_if.c
Allowed functions: None
Create a function ft_count_if
that counts elements in a string array that return 1
when passed to a given function.
Turn-in directory: ex27/
Files to turn in: Makefile
, and required files
Allowed functions: close
, open
, read
, write
Create a program ft_display_file
to display the content of a file given as an argument. Handle errors for missing, multiple, or unreadable files with appropriate messages.
Submit your assignments to your Git repository. Only the work inside your repository will be evaluated during defense. Double-check folder and file names for accuracy.