Thursday, April 26, 2018

Reverse words of a string

# include <stdio.h>
# include <conio.h>
# include <string.h>
main()
{
char str[50]="students love java, c++";
char st[50];
int i,j;
clrscr();
strrev(str);
puts(str);
for(i=0,j=0;str[i]!='\0';i++)
{
st[j++]=str[i];
if(str[i]==' ')
{
st[j]=NULL;
j=0;
printf("%s",strrev(st));
}
}
st[j]=NULL;
printf(" %s",strrev(st));
}

No comments:

Post a Comment