Reversing the words in a string
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[15] = "One Two Three";
int j = strlen(str)-1;
int i;
//clrscr();
while( j >= 0)
{
      while(str[j] != ' ' && j >= 0)
           j--;
        if (j >= 0) str[j] = '\0';
        i = j + 1;
      while(str[i] != '\0')
         printf("%c",str[i++]);
        if (j >= 0) printf(" ");
}
      getch();  
}
Pradyut 
 http://pradyut.tk
 http://groups.yahoo.com/group/d_dom/
 http://groups-beta.google.com/group/oop_programming
 
 
 
No comments:
Post a Comment