I am trying to write this shift function to print 5 times with a result of bcdea, cdeab, deabc, eabcd, abcde,,, I cannot get the function to work. Please point out my error... thanks in advance...
Code:
#include <stdio.h>
int main()
char shift(char *p1, char *p2, char *p3, char *p4, char *p5);
{
char c1='A',c2='B',c3='C',c4='D',c5='E';
int count=0;
printf("%c%c%c%c%c\n",c1,c2,c3,c4,c5);
while(count <= 4)
{
shift(&c1,&c2,&c3,&c4,&c5);
printf("%c%c%c%c%c\n",c1,c2,c3,c4,c5);
count++;
}
return 0;
}
char shift(char *p1, char *p2, char *p3, char *p4, char *p5)
{
char temp;
temp = *p5;
*p5 = *p4;
*p4 = *p3;
*p3 = *p2;
*p2 = *p1;
*p1 = temp;
}