42_EXAM
42_EXAM copied to clipboard
New exercises
exercises: ft_swapcases
, title
, and interval_spaces
.
Table of Contents
- ft_swapcases
- title
- interval_spaces
ft_swapcases
Assignment Name: ft_swapcases
Objective:
Write a program that takes a string as an argument and prints it with the case of each alphabetical character swapped (lowercase becomes uppercase and vice versa). Non-alphabetical characters remain unchanged.
Expected Files: ft_swapcases.c
Allowed Functions: write
Example Usage:
$> ./ft_swapcases "Hello World!" | cat -e
hELLO wORLD!$
$> ./ft_swapcases "42School" | cat -e
42sCHOOL$
$> ./ft_swapcases "" | cat -e
$
$> ./ft_swapcases | cat -e
$
Notes:
- If no arguments are provided, the program should simply print a newline.
- Handle both uppercase and lowercase letters.
- The program directly prints the modified string to standard output.
title
Assignment Name: title
Objective:
Write a program that takes a string as an argument and displays the string with the first letter of each word capitalized. Words are separated by spaces, and all non-alphabetical characters remain unchanged.
Expected Files: title.c
Allowed Functions: write
Example Usage:
$> ./title "hello world" | cat -e
Hello World$
$> ./title "this is a test" | cat -e
This Is A Test$
$> ./title "this is 42a test" | cat -e
This Is 42a Test$
$> ./title "MY TITLE" | cat -e
MY TITLE$
$> ./title "" | cat -e
$
$> ./title | cat -e
$
Notes:
- If the number of arguments is not exactly one, the program should print only a newline.
- The program capitalizes the first letter of each word while leaving the rest of the string unchanged.
interval_spaces
Assignment Name: interval_spaces
Objective:
Write a program that takes a string as an argument and displays each of its alphabetical characters separated by three spaces. The last character should be followed directly by a newline, without any trailing spaces. Non-alphabetical characters should be ignored.
Expected Files: interval_spaces.c
Allowed Functions: write
Example Usage:
$> ./interval_spaces "abc" | cat -e
a b c$
$> ./interval_spaces "abc def" | cat -e
a b c d e f$
$> ./interval_spaces "a1b2c3" | cat -e
a b c$
$> ./interval_spaces "Hello, World!" | cat -e
H e l l o W o r l d$
$> ./interval_spaces "" | cat -e
$
$> ./interval_spaces | cat -e
$
Notes:
- If the number of arguments is not exactly one, the program should print only a newline.
- Non-alphabetical characters are ignored, and the output has no trailing spaces.