Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. int main(void)
  6. {
  7.     char name[100];
  8.     char prev = ' ';        /* pretend there's a space before the string */
  9.     int n = 0;              /* number of initials printed */
  10.     int i = 0;
  11.  
  12.     printf("Enter the name: ");
  13.     fgets(name, sizeof(name), stdin);
  14.  
  15.     while (name[i]!='\0') {
  16.         if (isalpha(name[i]) && isspace(prev)) {
  17.             if (n++) putchar(' ');
  18.             putchar(name[i]);
  19.         }
  20.         prev = name[i];
  21.         i++;
  22.     }
  23.     putchar('\n');
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement