Can someone help me with array shifting. I am trying to shift an array a number of times that someone enters.
Example: The array is abcdef and I enter 1 to shift the array once. The output is bcdefa. If I enter 2 then the output is cdefab.
Here is my code so far. Can someone help me find out what I'm doing wrong. Thank you.
Code:
#include <stdio.h>
char shift( int yy, char loop[7]);
int main()
{
char loop[7] = "abcdef";
char arrloop[7];
int y;
printf("How many times do you want to shift this string?\n");
scanf("%d", y);
shift( y, char arrloop[7]);
printf("%s\n", loop);
}
{char shift(int yy, char loop[7]);
while( yy != 0)
{char x;
x = loop[5];
loop[5] = loop[4];
loop[4] = loop[3];
loop[3] = loop[2];
loop[2] = loop[1];
loop[1] = loop[0];
loop[0] = x;
yy--;}
printf("%s", loop);
getchar();
getchar();
return 0;
}