- What are pointers and how to use them
- What are arrays and how to use them
- What are the differences between pointers and arrays
- How to use strings and how to manipulate them
- Scope of variables
- tests: Tests files. Provided by Holberton School.
- _putchar.c: C function that writes a character to
stdout
. Provided by Holberton School.
- main.h: Header file containing prototypes for all programs written in this project.
File | Prototype |
---|---|
0-strcat.c | char *_strcat(char *dest, char *src); |
1-strncat.c | char *_strncat(char *dest, char *src, int n); |
2-strncpy.c | char *_strncpy(char *dest, char *src, int n); |
3-strcmp.c | int _strcmp(char *s1, char *s2); |
4-rev_array.c | void reverse_array(int *a, int n); |
5-string_toupper.c | char *string_toupper(char *); |
6-cap_string.c | char *cap_string(char *); |
7-leet.c | char *leet(char *); |
8-rot13.c | char *rot13(char *); |
100-print_number.c | void print_number(int n); |
102-infinite_add.c | char *infinite_add(char *n1, char *n2, char *r, int size_r); |
103-print_buffer.c | void print_buffer(char *b, int size); |
-
0. strcat
- 0-strcat.c: C function that concatenates two strings.
- Adds a terminating null byte at end.
- 0-strcat.c: C function that concatenates two strings.
-
1. strncat
- 1-strncat.c: C function that concatenates two strings using at most
an inputted number of bytes.
- Adds a terminating null byte at end, unless source string is longer than maximum byte number.
- 1-strncat.c: C function that concatenates two strings using at most
an inputted number of bytes.
-
2. strncpy
- 2-strncpy.c: C function that copies a string, including the
terminating null byte, using at most an inputted number of bytes.
- If the length of the source string is less than the maximum byte number, the remainder of the destination string is filled with null bytes.
- Works identically to the standard library function
strncpy
.
- 2-strncpy.c: C function that copies a string, including the
terminating null byte, using at most an inputted number of bytes.
-
3. strcmp
- 3-strcmp.c: C function that compares two strings.
- Returns the difference in bytes at point of difference.
- Works identically to the standard library function
strcmp
.
- 3-strcmp.c: C function that compares two strings.
-
4. I am a kind of paranoid in reverse. I suspect people of plotting to make me happy
- 4-rev_array.c: C function that reverses the content of an array of integers.
-
5. Always look up
- 5-string_toupper.c: C function that changes all lowercase letters of a string to uppercase.
-
6. Expect the best. Prepare for the worst. Capitalize on what comes
- 6-cap_string.c: C function that capitalizes all words of a string.
-
7. Mozart composed his music not for the elite, but for everybody
- 7-leet.c: C function that encodes a string into 1337, without
switch
or ternary operations and using only oneif
and two loops.- Letters
a
andA
are replaced by4
. - Leters
e
andE
are replaced by3
. - Letters
o
andO
are replaced by0
. - Letters
t
andT
are replaced by7
. - Letters
l
andL
are replaced by1
.
- Letters
- 7-leet.c: C function that encodes a string into 1337, without
-
8. rot13
- 8-rot13.c: C function that encodes a string to rot13, without
switch
or ternary operations and using only oneif
and two loops.
- 8-rot13.c: C function that encodes a string to rot13, without
-
9. Numbers have life; they're not just symbols on paper
- 100-print_number.c: C function that prints an integer
without using
long
, arrays, pointers, or hard-coded special values.
- 100-print_number.c: C function that prints an integer
without using
-
10. A dream doesn't become reality through magic; it takes sweat, determination and hard work
- 101-magic.c: C program that prints
a[2] = 98
using pointer magic.- Completion of this source code.
- 101-magic.c: C program that prints
-
11. It is the addition of strangeness to beauty that constitutes the romantic character in art
- 102-infinite_add.c: C function that adds two numbers stored
in strings to a buffer.
- Assumes that strings are never empty and that numbers will always be positive, or 0.
- Assumes there are only digits stored in the number strings.
- If result can be stored in the buffer, returns a pointer to the result.
- If result cannot be stored in the buffer, returns
0
.
- 102-infinite_add.c: C function that adds two numbers stored
in strings to a buffer.
-
12. Noise is a buffer, more effective than cubicles or booth walls
- 103-print_buffer.c: C function that prints the content of an
inputted number of bytes from a buffer.
- Prints 10 bytes per line.
- Starts with the position of the first byte in hexadecimal (8 chars), starting with
0
. - Each line shows the hexadecimal content (2 chars) of the buffer, 2 bytes at a time, separated by a space.
- Each line shows the content of the buffer. Prints the byte if it is printable; if not, prints
.
. - Each line ends with a new line
\n
. - If the inputted byte size is 0 or less, the function only prints a new line.
- 103-print_buffer.c: C function that prints the content of an
inputted number of bytes from a buffer.