Reverse a String in C Using Pointers – Three Approaches with Code

Reversing a string in C means rearranging its characters so the last character becomes the first and vice versa: “Hello” becomes “olleH”. The standard technique is the two-pointer swap — place one pointer at the start and one at the end, swap the characters they point to, then move the pointers toward each other until …

C Program to Encrypt and Decrypt a Password (XOR Cipher)

This classic exercise asks you to encrypt and decrypt a password in C. The right teaching tool for it is the XOR cipher: XOR each character with a key byte, and XOR-ing a second time with the same key restores the original — one function does both directions. This page gives you a tested implementation …

Anagram Program in C – Check if Two Strings are Anagrams

An anagram is a word or phrase formed by rearranging all the characters of another. In C, the standard way to check if two strings are anagrams is to count character frequencies: if both strings have exactly the same character counts, they are anagrams — regardless of order. This page shows a complete anagram program …

C Program to Delete Vowels from a String (In-Place, O(n))

Deleting the vowels from a string is a classic C exercise because the obvious approach — remove a character, then shift everything after it left by one — is O(n²) and fiddly. The clean solution is the two-index in-place filter: one index reads every character, a second index writes only the characters you’re keeping, and …

C Program to demonstrate strspn function.

Write a C Program to demonstrate strspn function.The strspn() function returns the index of the first character in string1 that doesn’t match any character in string2. If all the characters of the string2 matched with the string1, strspn returns the length of the string1. Read more about C Programming Language . /************************************************************ You can use …

Replace a Substring in C – Safe Replace-All Implementation

Replacing a substring means finding every occurrence of one piece of text inside a string and swapping it for another — for example, turning “the cat sat on the mat” into “the cog sog on the mog” by replacing “at” with “og”. C has no built-in function for this (unlike Python’s str.replace()), so it’s a …