Reverse a string word by word??

Answer Posted / vishnu948923

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{
int n,i,j=0;
char str[100];
char str1[100];
clrscr();
puts("Enter string:");
gets(str);
n=strlen(str);
for(i=n-1;i>=0;i--)
{
if(str[i]==' ')
{
str1[j]='\0';
strrev(str1);
printf("%s ",str1);
j=0;
}
else
{
str1[j++]=str[i];

}
}
if(i==-1)
{
str1[j]='\0';
strrev(str1);

printf("%s ",str1);
}
getch();
}

//strtoke
//isvowel

Is This Answer Correct ?    24 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an example of structure?

580


What is nested structure?

567


If I have a char * variable pointing to the name of a function ..

641


What are register variables? What are the advantage of using register variables?

671


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

1621






What does sizeof return c?

592


Explain how can you tell whether two strings are the same?

578


What is c++ used for today?

653


List some of the static data structures in C?

755


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

916


Why doesnt the call scanf work?

658


Is it better to use a macro or a function?

644


What is wrong with this code?

685


What is meant by operator precedence?

664


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

2565