In the 42 Network’s peer-to-peer curriculum, Exam Rank 03 is a significant milestone that tests a student’s mastery of the C programming language and foundational systems concepts. This 4-hour exam typically occurs during the "Common Core" phase and serves as a gatekeeper to more advanced ranks. Exam Structure & Core Concepts
The exam generally presents a single problem randomly selected from two main categories. You must validate the assigned question with a 100% score to pass the rank.
Custom Functions (ft_printf or get_next_line): In many versions of the curriculum, students are asked to recreate standard library functions. This requires handling file descriptors, memory allocation with malloc, and variadic arguments using va_start and va_arg.
Geometric Rendering (micro_paint and mini_paint): Some newer iterations of the exam focus on reading operation files to draw shapes (rectangles or circles) into a terminal buffer, emphasizing file parsing and logical 2D rendering.
Backtracking & Algorithms: Advanced variations might include algorithmic challenges like BSQ (Biggest Square), which requires optimizing how you search for patterns within a grid. Essential Preparation Strategies
Passing requires more than just knowing how to code; it requires speed and precision under pressure. Exam Rank 03 42
Simulated Practice: Use tools like the 42_examshell or JCluzet's 42_EXAM trainer to replicate the real exam environment, which includes a strict terminal-based interface and no internet access.
Single-File Constraints: Unlike standard projects, exam solutions are often required to be in a single .c file. Practice organizing your helper functions within one file to avoid compilation errors.
Memory Management: Since Norminette (the school’s code style checker) is often disabled during this exam, students sometimes overlook leaks. However, the automated "bot" grader will still fail you for memory leaks or segmentation faults.
Compiler Flags: Always test your code with -Wall -Wextra -Werror. These are the standard flags used by the grading system to ensure code quality. Student Resources
This is a detailed guide and walk-through for Exam Rank 03 at 42 Network. In the 42 Network’s peer-to-peer curriculum, Exam Rank
Status: This is the final rank for the "Beginner" cycle (Piscine style). Passing this unlocks the linear curriculum (Circle 4), where projects become much larger and collaborative.
The exam system at 42 (often called "Moulinette" for projects, though exams have a specific trainer) is unforgiving.
main function in your submission file. If you do, you get a 0.malloc is heavily tested), but if you use malloc, you must free. However, for most Rank 03 subjects, you can solve them without dynamic memory allocation, which is the preferred strategy.r → empty rectangle: only border pixels drawnR → filled rectangle: all inside pixels drawnx >= X && x <= X+W && y >= Y && y <= Y+Hx < X+1 || x > X+W-1 || y < Y+1 || y > Y+H-1 )ft_printfThis is the "Boss Fight" of Rank 03. If you get this, you must implement a simplified version of the standard printf.
The Prototype:
int ft_printf(const char *format, ...);
Mandatory Specifiers:
You usually need to handle: %c, %s, %p, %d, %i, %u, %x, %X, %%. Strictness: If the subject says "write a function,"
Key Concepts Needed:
<stdarg.h> macros (va_start, va_arg, va_end).printf or putchar, you must use write.Suggested Logic Structure:
Iterate through the format string:
%, write it and increment counter.%, look at the next character and branch logic.Helper Functions:
You need a function to print strings (%s), characters (%c), and numbers. Printing numbers (especially hex) requires a recursive or division-based helper function.
Example Skeleton:
#include <stdarg.h>
#include <unistd.h>
// Helper to write a single char
void ft_putchar(char c, int *count)
write(1, &c, 1);
*count += 1;
// Helper to write a string
void ft_putstr(char *str, int *count)
if (!str)
str = "(null)";
while (*str)
ft_putchar(*str, count);
str++;
// Helper for base conversion (Hex and Decimal)
void ft_putnbr_base(unsigned long long n, int base, char *chars, int *count)
if (n >= (unsigned long long)base)
ft_putnbr_base(n / base, base, chars, count);
ft_putchar(chars[n % base], count);
// Helper for signed integers (d, i)
void ft_putnbr(int n, int *count)
if (n == -2147483648)
ft_putstr("-2147483648", count);
return;
if (n < 0)
ft_putchar('-', count);
n = -n;
ft_putnbr_base((unsigned long long)n, 10, "0123456789", count);
// Main function
int ft_printf(const char *format, ...)
va_list args;
int count = 0;
va_start(args, format);
while (*format)
if (*format == '%')
*format == 'i') ft_putnbr(va_arg(args, int), &count);
else if (*format == 'u') ft_putnbr_base(va_arg(args, unsigned int), 10, "0123456789", &count);
else if (*format == 'x') ft_putnbr_base(va_arg(args, unsigned int), 16, "0123456789abcdef", &count);
else if (*format == 'X') ft_putnbr_base(va_arg(args, unsigned int), 16, "0123456789ABCDEF", &count);
else if (*format == 'p')
ft_putstr("0x", &count);
ft_putnbr_base((unsigned long long)va_arg(args, void *), 16, "0123456789abcdef", &count);
else if (*format == '%') ft_putchar('%', &count);
else
ft_putchar(*format, &count);
format++;
va_end(args);
return (count);
Common Pitfalls:
printf("%s", NULL) prints (null). Your code must handle this or it will segfault.%x is lowercase, %X is uppercase. Don't mix them up.%p prints a memory address. On 64-bit systems, this is larger than an unsigned int. Cast to unsigned long long.max_xmax_y'r' for rect in micro; 'c' for circle in mini)'R' for rectangle outline, 'r' for filled; similarly 'C' / 'c' for circle)'X' or '#')sqrt((x - X)^2 + (y - Y)^2) <= Radius. A point is on the border if the absolute difference between distance and radius is less than a threshold (usually 1.0). For filled circles, draw if inside.stdout.