[ create a new paste ] login | about

Link: http://codepad.org/ADzSjzYj    [ raw code | output | fork ]

PhoeniX888 - C, pasted on Jul 25:
//Reverse order of words

#include "string.h"
void string_manip(char * str)
{
printf("Input -- > %s\n",str); 
printf("Output-- >"); 
	int l = strlen(str);
	int j = 0;
        int i = l-1;
	for(i; i >= 0 ; i--)
	{
		if(str[i] == ' ' || (i == 0))
		{
			j = (i == 0 ? i:i+1);
			while(str[j] != ' ' && str[j] != '\0')
			{
				printf("%c",str[j++]);
			}
			printf(" ");
		}
	}
}
void main()
{
    string_manip("This is Big");
printf("\n");
string_manip("This function is called by the UI Framework");

}


Output:
1
2
3
4
Input -- > This is Big
Output-- >Big is This 
Input -- > This function is called by the UI Framework
Output-- >Framework UI the by called is function This 


Create a new paste based on this one


Comments: