- Read the resources from the previous project; 0x05. C - Pointers, arrays and strings.
- strcat : A C function program that concatenates two strings.
- Prototype:
char *_strcat(char *dest, char *src);
- This function appends the src string to the dest string, overwriting the terminating null byte (
\0
) at the end ofdest
, and then adds a terminating null byte. - Returns a pointer to the resulting string
dest
. - FYI: The standard library provides a similar function:
strcat
. Runman strcat
to learn more. - Read more on strcat here.
- Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 0-main.c 0-strcat.c -o 0-strcat
- Prototype:
- strncat : A C function program that concatenates two strings.
- Prototype:
char *_strncat(char *dest, char *src, int n);
- The
_strncat
function is similar to the_strcat
function, except that- it will use at most
n
bytes fromsrc
; and src
does not need to be null-terminated if it containsn
or more bytes
- it will use at most
- Return a pointer to the resulting string
dest
. - FYI: The standard library provides a similar function:
strncat
. Runman strncat
to learn more. - Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 1-main.c 1-strncat.c -o 1-strncat
- Prototype:
- strncpy : A C function program that copies a string.
- Prototype:
char *_strncpy(char *dest, char *src, int n);
- Your function should work exactly like
strncpy
. - FYI: The standard library provides a similar function:
strncpy
. Runman strncpy
to learn more. - Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 2-main.c 2-strncpy.c -o 2-strncpy
- Prototype:
- strcmp : A C function program that compares two strings.
- Prototype:
int _strcmp(char *s1, char *s2);
- Your function should work exactly like
strcmp
. - FYI: The standard library provides a similar function:
strcmp
. Runman strcmp
to learn more. - Read an example here to understand
- Remember:
- The
strcmp
returns the following;- 0 if
s1
ands2
are equal - Negative integer if the stopping character in
s1
was less than the stopping character ins2
- Positive integer if the stopping character in
s1
was greater than the stopping character ins2
- 0 if
- So when we compare we will only check the difference of the first character found between
s1
ands2
, break the array iteration and return the difference.
- The
- Remember:
- Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 3-main.c 3-strcmp.c -o 3-strcmp
- Prototype:
- I am a kind of paranoid in reverse. I suspect people of plotting to make me happy : A C function program that reverses the content of an array of integers.
- Prototype:
void reverse_array(int *a, int n);
- Where
n
is the number of elements of the array. - Read an example here on how to swap
n
is the number of elements in the array Read here for more information.- Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 4-main.c 4-rev_array.c -o 4-rev_array
- Prototype:
- Always look up : A C function program that changes all lowercase letters of a string to uppercase.
- Prototype:
char *string_toupper(char *);
- Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 5-main.c 5-string_toupper.c -o 5-string_toupper
- Prototype:
- Expect the best. Prepare for the worst. Capitalize on what comes : A C function program that capitalizes all words of a string.
- Prototype:
char *cap_string(char *);
- Separators of words: space, tabulation, new line,
,
,;
,.
,!
,?
,"
,(
,)
,{
, and}
. - Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 6-main.c 6-cap_string.c -o 6-cap
- Prototype:
- Mozart composed his music not for the elite, but for everybody : A C function program that encodes a string into 1337.
- Prototype:
char *leet(char *);
- You can only use one
if
in your code. - You can only use two loops in your code.
- You are not allowed to use
switch
. - You are not allowed to use any ternary operation.
- Letters
a
andA
should be replaced by4
. - Letters
e
andE
should be replaced by3
. - Letters
o
andO
should be replaced by0
. - Letters
t
andT
should be replaced by7
. - Letters
l
andL
should be replaced by1
.
- Letters
- Compile the code this way:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 7-main.c 7-leet.c -o 7-1337
- Prototype: