Vision and dreams are the blueprints of soul and achievements.
-Mohammed Ahmed F

Reverse all words but not the string using pointer

To write a C program to accept a string from the user and reverse all words but not the string using pointer.

String: sihT sI A dooG golB
Result: This Is A Good Blog


Solution:-

//C program for reverse all words but not the string using pointer

‪#‎include‬<stdio.h>
#include<conio.h>
int main()
{
char str[30];
char *p,*tmp;
printf("Enter any string: ");
gets(str);
for(p=str; *p!='\0'; p++)
{
if(*(p+1)==' ' || *(p+1)=='\0')
{
for(tmp=p; *tmp!=' ' && tmp>=str; tmp--)
printf("%c",*tmp);
}
printf(" ");
}
getch();
return 0;
}

Share this

Related Posts

Dear User,

Thank you for your comment. Hope you like this blog. Kindly share us on Social Media so others can be updated.

-Chief Administrative Officer.