ctype


1. Checking Character Type

#include <ctype.h>

int main() {
  char c = 'a';
  if (isalpha(c)) {
    printf("Character %c is an alphabet.\n", c);
  } else if (isdigit(c)) {
    printf("Character %c is a digit.\n", c);
  } else if (isspace(c)) {
    printf("Character %c is a whitespace.\n", c);
  }
  return 0;
}

2. Converting Character Case

#include <ctype.h>

int main() {
  char c = 'a';
  c = toupper(c);  // Convert 'a' to 'A'
  printf("Uppercase character: %c\n", c);
  return 0;
}

3. Removing Punctuation

4. Extracting Integers from a String

5. Tokenizing a String

6. Ignoring Case in String Comparisons

7. Validating Email Addresses

8. Encrypting Text using Caesar Cipher

9. Checking for Numeric Input

10. Removing Duplicate Characters

11. Counting Words in a String

12. Finding the Length of a String without Using strlen

13. Reversing a String

14. Converting a Hexadecimal String to an Integer

15. Checking for Balanced Parentheses

16. Counting Occurrences of a Character

17. Removing Leading and Trailing Whitespace

18. Capitalizing the First Letter of a String

19. Finding the Minimum and Maximum Values in a String

20. Finding the Most Frequently Occurring Character

21. Removing Consecutive Duplicates

22. Finding the Position of the Last Occurrence of a Character

23. Converting a String to Uppercase

24. Converting a String to Lowercase

25. Counting the Number of Vowels in a String

26. Validating a Password

27. Finding the Length of the Longest Word

28. Normalizing a String (Removing Punctuation, Extra Whitespace)

29. Finding the Common Prefix of Two Strings

30. Truncating a String to a Specified Length

31. Generating a Random String

32. Comparing Strings Case-Insensitive

33. Replacing Occurrences of a Character

34. Encrypting Text using XOR Cipher

35. Decrypting Text Encrypted by XOR Cipher

36. Converting a Number to a Roman Numeral

37. Converting a Roman Numeral to a Number

38. Finding the ASCII Value of a Character

39. Converting a Character to its ASCII Code

40. Checking if a String is a Palindrome

41. Finding the First Non-Repeating Character

42. Checking if a String Contains All Unique Characters

43. Converting a String to Camel Case

44. Finding the Number of Words in a String Using isspace

45. Checking if a Character is a Hexadecimal Digit

46. Converting a Character to its Lowercase Equivalent

47. Checking if a String is in Title Case

48. Finding the Number of Different Characters in a String

49. Creating a Histogram of Characters in a String

50. Comparing if Two Strings are Anagrams