This directory contains C programs that demonstrate the use of pointers, arrays, and strings in various functions. Each program focuses on a specific task and provides a solution using C programming concepts.
- File:
0-reset_to_98.c
- Description: This function takes a pointer to an integer as a parameter and updates the value it points to, setting it to 98.
- Prototype:
void reset_to_98(int *n)
- Usage: The function can be called to update an integer to 98.
- File:
1-swap.c
- Description: This function swaps the values of two integers using pointers.
- Prototype:
void swap_int(int *a, int *b)
- Usage: The function can be called to swap the values of two integers.
- File:
2-strlen.c
- Description: This function returns the length of a string (the number of characters in it) excluding the null terminator '\0'.
- Prototype:
int _strlen(char *s)
- Usage: The function can be called to find the length of a string.
- File:
3-puts.c
- Description: This function prints a string followed by a new line to the standard output (stdout).
- Prototype:
void _puts(char *str)
- Usage: The function can be called to print a string.
- File:
4-print_rev.c
- Description: This function prints a string in reverse order followed by a new line.
- Prototype:
void print_rev(char *s)
- Usage: The function can be called to print a string in reverse.
- File:
5-rev_string.c
- Description: This function reverses a string in place.
- Prototype:
void rev_string(char *s)
- Usage: The function can be called to reverse a string.
- File:
6-puts2.c
- Description: This function prints every other character of a string, starting with the first character, followed by a new line.
- Prototype:
void puts2(char *str)
- Usage: The function can be called to print every other character of a string.
- File:
7-puts_half.c
- Description: This function prints the second half of a string, followed by a new line. If the number of characters is odd, it prints the last
n
characters of the string, wheren = (length_of_the_string - 1) / 2
. - Prototype:
void puts_half(char *str)
- Usage: The function can be called to print the second half of a string.
- File:
8-print_array.c
- Description: This function prints
n
elements of an array of integers, followed by a new line. The numbers are separated by commas and spaces. - Prototype:
void print_array(int *a, int n)
- Usage: The function can be called to print elements of an integer array.
- File:
9-strcpy.c
- Description: This function copies the string pointed to by
src
, including the terminating null byte (\0
), to the buffer pointed to bydest
. - Prototype:
char *_strcpy(char *dest, char *src)
- Return Value: The pointer to
dest
. - Usage: The function can be called to copy a string.
- File:
100-atoi.c
- Description: This function converts a string to an integer.
- Prototype:
int _atoi(char *s)
- Return Value: The converted integer.
- Usage: The function can be called to convert a string to an integer.
Happy coding! 🚀