VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-print-the-first-letter-of-each-word/

⇱ C Program to Print the First Letter of Each Word - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Print the First Letter of Each Word

Last Updated : 23 Jul, 2025

In a string that contains multiple words, each word is separated by a whitespace. In this article, we will learn how to print the first letter of each word using a C program.

The simplest method to print the first letter of each word is by using a loop. Let’s take a look at an example:


Output
H G W t C p 

Explanation: We traverse the string, and every time we find a non-space character that follows a space (or is at the start of the string), we print that character.

There are also a few other methods in C to print the first letter of each word. They are as follows:

Using strtok()

Another approach is to use the strtok()function, which breaks a string into tokens based on delimiters. We can use space ' ' as the delimiter to extract each word from the string and print the first character of each word.


Output
H G W t C p 

Using sscanf()

We can also usesscanf() to read individual words from the string, one by one, and print the first letter of each word. This approach works by scanning each word and extracting the first character.


Output
H G W t C p 
Comment
Article Tags: