//Word wise string reverse
#include
#include
void main()
{
clrscr();
char str[50],word[10][15];
int i=0,l=0,len_word[10],k,j,o=0,p=0,a[10];
printf("Enter a string:");
gets(str);
a[0]=-1;
for(i=1;i<10;i++)
a[i]=0;
i=0;
while(str[i]!='\0')
{
k=0;
while(str[i]!=' ')
{
if(str[i]=='.')
{
a[o]=l;o++;break;
}
if(str[i]=='\0')
{
i=i-1;break;
}
word[l][k]=str[i];
i++;k++;
}
i++;len_word[l]=k;l++;
}
for(i=0;i=0;j--)
printf("%c",word[i][j]);
if(i==a[p])
{
p++;
printf(".");
}
else
printf(" ");
}
getch();
}
0 comments:
Post a Comment