|
Hi,
Scroll Down.
Here's a way of reversing your
sentence.
void reverse(char
*t);
#include<stdio.h>
int main() { char *s; // Eg input sentence: "My name is XYZ"
printf("Enter a sentence:\n");
gets(s);
reverse(s);
printf("%s",s); //print the reversed string :O/p is: "ZYX si eman yM" return 0; } void reverse(char *t) { int i,j; char temp; for(i=0,j=strlen(t)-1;i<j;i++,j--) temp=t[i],t[i]=t[j],t[j]=temp; } However if you wanted the output as "XYZ is name My", You need to individually reverse the
words of the reversed sentence.
Use the logic and thats an assignment for
you.
HTH
-Ravi
To unsubscribe : [EMAIL PROTECTED]
Yahoo! Groups Links
|
- (PT) HELP(reverse line) Aniruddha Pawde
- Re: (PT) HELP(reverse line) Fernando Arturo G�mez Flores
- (PT) (RE) HELP(reverse line) deo sharma
- Ravi Pandit
