faqts : Computers : Programming : Languages : C

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 4 people (100%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

programme for All rotations of a string Ex:-space 1.paces 2. acesp 3. cespa 4. espac

Apr 14th, 2005 02:30
Ankit Sharma, sumit sood,


Following is the solution for this:
You can change the input mechanism of this program, i hav taken the 
hardcoded string...
#include <string.h>
main()
{
	char str[]="space";
	char *ptr=str;
	int i=0,j=0;
	while(i<=strlen(str))
	{
		printf("%s",(ptr+i));
		while(j<i)
		   putchar(*(ptr+j++));
		i++;
		j=0;
		printf("\n");
	}
}