C Piscine Exam 01
C Piscine — Exam 01 (Comprehensive Study Guide)
Level 0: The Warm-up
1. aff_a
- Task: Write a program that takes a string as an argument and displays 'a' if the string contains one, followed by a newline. If no 'a', just newline.
- Logic: Loop through
argv[1]. Ifstr[i] == 'a', write it. Note: Some versions ask to display 'a' regardless, others only if found. Check the subject text carefully. - Key Concept:
write,main(int argc, char **argv).
2. aff_first_param
- Task: Display the first command-line argument.
- Logic: Check if
argc > 1. If so, loop throughargv[1]and write characters. If no args, just newline. - Key Concept: Accessing
argv.
What Happens If You Fail Exam 01?
Relax. Failure is part of the 42 pedagogy. c piscine exam 01
- Retake opportunities: You can retake the exam during the next scheduled session (often within 48-72 hours).
- No GPA penalty (sort of): Your final Piscine grade takes the best of your attempts. However, failing twice in a row flags you for peer review.
- The real cost: Wasted time. While you retake Exam 01, your peers are moving on to C07, C08, and the Rush projects.
Level 0 & 1 (Warm-up, but deceptive)
ft_strlen– Return the length of a string. Easy, but don’t forget the null terminator isn’t counted.ft_putstr– Write a string to standard output. You must usewrite(1, &c, 1)inside a loop.ft_strcmp– Compare two strings lexicographically. Remember the trick:while (*s1 && (*s1 == *s2)) s1++; s2++; return (*s1 - *s2);.