Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //wap to convert a given string into sentence case//
- #include <stdio.h>
- int StrToSentence(char * str)
- {
- int len=0,i=0;
- len = strlen(str);
- for(i=0;i<len;i++)
- {
- if( (i==0) && (str[i]>='a' && str[i]<='z'))
- {
- str[i] = str[i] - 32;
- }
- else if(str[i]=='.')
- {
- if(str[i+1] == ' ')
- {
- if(str[i+2]>='a' && str[i+2]<='z')
- {
- str[i+2] = str[i+2] - 32;
- }
- }
- else
- {
- if(str[i+1]>='a' && str[i+1]<='z')
- {
- str[i+1] = str[i+1] - 32;
- }
- }
- }
- }
- }
- int main()
- {
- char str[100]={0};
- int len=0,i=0,j=0,k=0;
- printf("\nEnter string : ");
- gets(str);
- StrToSentence(str);
- printf("Final string is : %s",str);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement