#include <stdio.h>
#include <conio.h>
void getString(char *);
int my_strlen(char *str);
void recurse_word(char *, int );
char *word;
char *word1;
int word_len=0;
void main()
{
clrscr();
word = (char *) malloc(sizeof(char)*10);
word1 = (char *) malloc(sizeof(char)*10);
printf("Enter any word of maximum 10 character : ");
getString(word);
word_len = my_strlen(word);
recurse_word(word, word_len);
getch();
}
void recurse_word(char *str, int call_time)
{
int count = 0;
char first_chr = *str;
char *tmp_word = str;
char *tword = tmp_word;
char tmpchr;
if( call_time <= 0)
return;
printf("\n%s", str);
for(count=0; count<word_len-1; count++)
{
tmp_word++;
*tword = *tmp_word;
tword++;
}
*tword = first_chr;
recurse_word(str, --call_time);
}
void getString(char *str)
{
int count=0;
char *getstr;
char readch='\0';
fflush(NULL);
getstr = str;
while(1)
{
scanf("%c", &readch);
if( readch == '\n')
break;
*getstr = readch;
//if( ( str = (char *)realloc(str, sizeof(char)) ) == '\0')// break;
count++;
getstr++;
if( count >= 10)
break;
}
*getstr='\0';
}
int my_strlen(char *str)
{
int _tmpval = 0;
char *cstr = str;
if(*cstr != '\0')
{
while(*cstr !='\0')
{
_tmpval++;
cstr++;
}
}
return _tmpval;
}
/******************** Input **********************
Enter any word of maximum 10 character : space
******************** Output **********************
space paces acesp cespa espac
*/