abbreviate name using string in c

Solutions on MaxInterview for abbreviate name using string in c by the best coders in the world

showing results for - "abbreviate name using string in c"
Alex
12 Jan 2020
1#include <stdio.h>
2#include <string.h>
3
4void main()
5{
6    char str[100];
7
8    int len,i,a;
9
10    printf("enter your name: ");
11
12    gets(str);
13
14    len = strlen(str);
15
16    printf("%c.",(str[0]));
17
18    for(i=0;i<len;i++)
19    {
20        if(str[i]==' ')
21        {
22            a=i;
23        }
24    }
25
26    for(i=0; i<a; i++)
27    {
28        if(str[i]==' ')
29        {
30            printf("%c.", str[i+1]);
31        }
32    }
33
34    for(i=a+1;i<len;i++)
35    {
36        printf("%c",str[i]);
37    }
38}
39