Skip to content

Commit

Permalink
Merge pull request vglug#2 from dilip0207/dilip0207-patch-2
Browse files Browse the repository at this point in the history
common_first_character_words_in_string
  • Loading branch information
dilip-hari authored Oct 30, 2021
2 parents d03947d + 27c0dda commit d4de613
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions c/common_first_character_words_in_string
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include<stdio.h>
#include<string.h>
int findlength(char s[])
{
int i,count=0;
for(i=0;s[i]!='\0';i++)
{
count++;
}
return count;
}
void main()
{
int i,n,j;
char s[30];
gets(s);
n=findlength(s);
for(i=0;i<n;i++)
{
if(s[i]!=' ')
{
printf("%c",s[i]);
}
else
break;
}
printf(" ");
i++;
for(;i<n;i++)
{
if(s[0]==s[i] && s[i-1]==' ')
{
for(j=i;j<n;j++)
{
if(s[j]!=' ')
{
printf("%c",s[j]);
}
else
break;
}
printf(" ");
}
}
}

0 comments on commit d4de613

Please sign in to comment.