This function removes trailing whitespace (spaces and tabs) from a string. It works by iterating from the end of the string and replacing whitespace characters with null terminators until a non-whitespace character is encountered.
This code converts all lowercase letters in a string to uppercase. It uses the toupper
function from <ctype.h>
and iterates through each character of the string using a pointer.
This code pads a string with leading spaces to reach a desired length.
This code converts all uppercase letters in a string to lowercase using ASCII value manipulation.
This function reverses a string in-place. It uses two pointers, one starting from the beginning and one from the end, swapping characters as it moves towards the center of the string.
This snippet copies a string from src
to dest
, including the null terminator. It's similar to the standard strcpy
function, using pointer arithmetic to efficiently copy characters one by one.
This code calculates the length of a string manually by counting characters until the null terminator.
This code compares two strings manually, character by character, returning the difference between the first non-matching characters.
This code finds the first occurrence of a specific character in a string. It returns a pointer to the character if found, or NULL if not found. The function iterates through the string, comparing each character to the target.
This function counts the number of times a substring appears within a larger string using the strstr function.
This code checks if a string is a palindrome by comparing characters from both ends towards the middle, ignoring case.
This function concatenates two strings by appending the source string to the destination string.
This code demonstrates string tokenization using strtok(). It splits a string into tokens based on a delimiter.
This code performs basic string compression by replacing repeated characters with the character followed by its count.